run function block in context of global namespace in PHP

thcoder

New Member
So the senario is that I want to have a custom function for requiring libraries. Something like:\[code\]define('E_ROOT', str_replace('//','/',dirname(__FILE__)));/* ... */function e_load($fn, $allowReloading = FALSE) { $inc = E_ROOT.'/path/here/'.$fn.'.php'; if($allowReloading) require $inc; // !!! else require_once $inc; // !!!}\[/code\]The problem being that \[code\]require\[/code\] and \[code\]require_once\[/code\] will load the files into the namespace of the function, which doesn't help for libraries of functions, classes, et cetera. So is there a way to do this? (Something avoiding \[code\]require\[/code\] and \[code\]require_once\[/code\] altogether is fine, as long as it doesn't use \[code\]eval\[/code\] since it's banned on so many hosts.)Thanks!
 
Back
Top