What are common pitfalls to avoid when using variable scope in PHP?

One common pitfall to avoid when using variable scope in PHP is accidentally creating global variables when they are not needed. To prevent this, always declare variables within the appropriate scope (e.g., within a function if they are only needed there). Additionally, be cautious when using global variables as they can lead to unexpected behavior and make code harder to maintain.

function myFunction() {
    $localVariable = "I am a local variable";
    
    // Use $localVariable within this function
}