What are common pitfalls when working with PHP variables and how can they be avoided?

One common pitfall when working with PHP variables is not properly initializing them before use, which can lead to unexpected errors. To avoid this, always initialize variables with a default value before using them in your code.

// Incorrect way
$variable; // uninitialized variable

// Correct way
$variable = ''; // initialize variable with a default value