How can global variables be used within functions in PHP?

Global variables can be accessed within functions in PHP by using the `global` keyword to explicitly declare the variable as global within the function scope. This allows the function to access and modify the global variable directly. However, it is generally considered best practice to avoid using global variables within functions as it can lead to code that is harder to maintain and debug.

$globalVar = 10;

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

myFunction(); // Output: 10