How can global variables be accessed within functions in PHP?

Global variables can be accessed within functions in PHP by using the `global` keyword inside the function to access the variable's global scope. This allows the function to read and modify the global variable within its local scope. It is important to use global variables carefully to avoid potential conflicts and unintended consequences in your code.

$globalVar = 10;

function accessGlobalVariable() {
    global $globalVar;
    echo $globalVar;
}

accessGlobalVariable(); // Output: 10