How can the global keyword be used to access variables in included scripts in PHP?

When including scripts in PHP, variables defined in the included script are not automatically accessible in the main script. To access these variables, you can use the global keyword within the included script to make the variables available globally. This allows you to access the variables in the main script as well.

// main_script.php
$var = 'Hello';

// included_script.php
global $var;
echo $var; // Output: Hello