How can variables defined in an included file be accessed in the main PHP script?

Variables defined in an included file can be accessed in the main PHP script by using the global keyword to make the variables accessible outside of the included file's scope. This allows the main script to access and utilize the variables defined in the included file.

// included_file.php
$included_variable = "Hello from included file!";

// main_script.php
include 'included_file.php';

global $included_variable;
echo $included_variable; // Output: Hello from included file!