How can global variables be used and updated in PHP functions?
Global variables can be accessed and updated within PHP functions by using the `global` keyword to declare the variable within the function's scope. This allows the function to access and modify the global variable directly. However, it is generally considered best practice to pass variables as parameters to functions rather than relying on global variables.
$globalVar = 10;
function updateGlobalVar() {
global $globalVar;
$globalVar += 5;
}
updateGlobalVar();
echo $globalVar; // Output: 15