How can global variables impact the security of PHP code?

Global variables can impact the security of PHP code by making it vulnerable to injection attacks and unintended modifications. To mitigate this risk, it is recommended to avoid using global variables whenever possible and instead use local variables within functions or classes.

function myFunction() {
    $localVar = "This is a local variable";
    
    // Use $localVar within the function
}