How should global variables be defined and used in PHP functions?

Global variables in PHP functions can be defined using the `global` keyword followed by the variable name inside the function. This allows the function to access and modify the global variable. However, it is generally considered a better practice to pass variables as parameters to functions rather than relying on global variables. If you must use global variables, make sure to use them carefully to avoid unexpected behavior.

$globalVar = 10;

function myFunction() {
    global $globalVar;
    $globalVar += 5;
}

myFunction();
echo $globalVar; // Outputs 15