How can PHP variables be properly utilized and accessed outside of a function scope?

PHP variables can be accessed outside of a function scope by declaring them as global variables within the function. This allows the variables to be used outside of the function where they were originally defined. By using the "global" keyword before the variable name within the function, the variable can be accessed and modified globally.

$globalVar = 10;

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

myFunction();
echo $globalVar; // Output: 15