Re: get_called_class returns empty on spl_autoload*

From: Date: Sun, 26 Apr 2009 23:27:32 +0000
Subject: Re: get_called_class returns empty on spl_autoload*
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-43782@lists.php.net to get a copy of this message
Hm, probably it's my version of PHP 5.3, I noticed I've beta1.... I'll compile a new one and let you know if I still have issues :-) I'm also testing on MacOS. On Sun, Apr 26, 2009 at 6:13 PM, Etienne Kneuss <webmaster@colder.ch> wrote: > Hello, > > On Sun, Apr 26, 2009 at 11:28 PM, Pablo Fischer <pfischer@php.net> wrote: >> 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 >> > > I can't reproduce, can you check with latest 5_3 ? > > Thanks in advance. > >> 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 >> >> > > > > -- > Etienne Kneuss > http://www.colder.ch > > Men never do evil so completely and cheerfully as > when they do it from a religious conviction. > -- Pascal > -- Pablo Fischer (pablo [arroba/at] pablo.com.mx)

« previous php.internals (#43782) next »