Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.
Magic method __autoload implementation. - PHP Code Bank
Magic method __autoload implementation.
This featuere implements an __autoload magic method to classes.
In other words, a class can have a Autoloder of their own.
function autoloadProxy($className)
{
// Fetch last backtrace from this call and backwards
$trace = debug_backtrace();
// Pops of one key from the backtrace untill it's completly empty (NULL)
while (($next = array_pop($trace)) != NULL) {
/* If $next has the key 'object' then it's a class call and should be tested for method existence.
If method '__autoload' exists in the class that was called then call that method. */
if (isset($next['object']) && method_exists($next['object'], '__autoload')) {
return $next['object']->__autoload($className);
}
}
/* If no matches were found then it means we failed to localize an '__autoloader' method.
Add fallback method here or just return false, remember that before PHP 5.3 and autoloader can't throw (raise) an exception. */
return false;
}
// Register the proxy.
spl_autoload_register('autoload_proxy');
Comments
ghost 14 years ago
The code might be buggy, I did a last minute change to move down the trace stack which I yet to have tested.