I\'m looking for a way to set the scope of require_once()
to the global scope, when require_once()
is used inside a function. Something like the follow
You will need to declare global in your foo.php
:
Otherwise it's probably not possible.
You could try to play around with extract()
, get_defined_vars()
, global
and $GLOBALS
in various combinations maybe... like iterating through all defined variables and calling global on them before requiring a file...
$vars = get_defined_vars();
foreach($vars as $varname => $value)
{
global $$varname; //$$ is no mistake here
}
require...
But i'm not quite sure if you get to where you want to go...