How can the scope of variables be managed when using the include() function in PHP?

When using the include() function in PHP, the scope of variables can be managed by using the global keyword to access variables defined outside of the included file. This allows the included file to access and modify variables from the parent file without causing conflicts or scope issues.

// parent.php
$variable = "Hello";

// included.php
function printVariable() {
    global $variable;
    echo $variable;
}

include('parent.php');
printVariable(); // Output: Hello