What are the best practices for handling global variables in PHP functions, especially in the context of WordPress development?

When working with global variables in PHP functions, especially in the context of WordPress development, it's important to use them sparingly and with caution to prevent conflicts and unexpected behavior. One best practice is to pass variables as parameters to functions instead of relying on global scope. This helps improve code readability, maintainability, and reduces the risk of variable contamination.

// Example of passing variables as parameters instead of using global scope
function my_function($my_variable) {
    // Function logic using $my_variable
}

// Usage of the function with a specific variable
$my_variable = 'Hello World';
my_function($my_variable);