Hello,
Was playing with get_called_class inside an autoload method that is
registered via spl_autoload_register and noticed:
- If I use get_called_class inside an autoload method I get an empty
value from it
- However the same doesn't happen if I'm not using a registered autoload method
Was wondering if this is a bug, a feature or something I'm just missing :-)
The code I'm using is:
class Loader {
public static function autoload($className)
{
var_dump('Calling ' . get_called_class() . ' for ' . $className);
}
public static function getCalledClass()
{
var_dump('Current class is: ' . get_called_class());
}
}
spl_autoload_register(array('Loader', 'autoload'));
Loader::getCalledClass();
$foo = new Foo;
And I get:
string(24) "Current class is: Loader"
string(16) "Calling for Foo"
Fatal error: Class 'Foo' not found in
/Users/pablo/Projects/reptilia/test.php on line 17
Thanks!
--
Pablo Fischer (pablo [arroba/at] pablo.com.mx)
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php