What are some potential pitfalls of using static variables in PHP functions?

Using static variables in PHP functions can lead to unexpected behavior if not managed properly. One potential pitfall is that static variables retain their values between function calls, which can cause unintended side effects if the variable is not reset when needed. To avoid this issue, it's important to carefully manage the initialization and resetting of static variables within the function.

function exampleFunction() {
    static $counter = 0; // Initialize static variable
    
    // Do something with $counter
    
    $counter++; // Increment counter
    
    // Reset counter if needed
    if ($counter >= 10) {
        $counter = 0;
    }
}