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
Apart from "globalizing" your variable, there is no way to do this:
global $foo;
$foo = 42;
OR
$GLOBALS['foo'] = 42;
Then your value should be 42 when you print it out.
UPDATE
Regarding the inclusion of classes or functions, note that all functions and classes are always considered global unless we are talking about a class method. At that point, the method in a class is only available from the class definition itself and not as a global function.