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)
Hello,
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 methodWas 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)
--
--
Etienne Kneuss
http://www.colder.ch
Men never do evil so completely and cheerfully as
when they do it from a religious conviction.
-- Pascal
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.
Hello,
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 methodWas 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 17I can't reproduce, can you check with latest 5_3 ?
Thanks in advance.
Thanks!
Pablo Fischer (pablo [arroba/at] pablo.com.mx)
--
--
Etienne Kneuss
http://www.colder.chMen 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)
Hi,
Well, I upgraded my php5.3 version and I still see the same thing:
$ php test.php
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
$ php --version
PHP 5.3.0RC1 (cli) (built: Apr 27 2009 11:12:36)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies
As I said, not sure if this is the way spl_autoload_register should
work with get_called_class()
.
thanks!
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.
Hello,
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 methodWas 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 17I can't reproduce, can you check with latest 5_3 ?
Thanks in advance.
Thanks!
Pablo Fischer (pablo [arroba/at] pablo.com.mx)
--
--
Etienne Kneuss
http://www.colder.chMen 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)
--
Pablo Fischer (pablo [arroba/at] pablo.com.mx)
Hi,
Well, I upgraded my php5.3 version and I still see the same thing:
[...]
PHP 5.3.0RC1 (cli) (built: Apr 27 2009 11:12:36)
What about CVS?
As I said, not sure if this is the way spl_autoload_register should
work withget_called_class()
.
It works fine for me:
string(24) "Current class is: Loader"
string(22) "Calling Loader for Foo"
PHP Fatal error: Class 'Foo' not found in /usr/src/php/5.3/- on line 15
-Hannes
Hm, very strange, perhaps I'm building it with port (mac)?
$ sudo port install php5-devel
On Mon, Apr 27, 2009 at 2:03 PM, Hannes Magnusson
hannes.magnusson@gmail.com wrote:
Hi,
Well, I upgraded my php5.3 version and I still see the same thing:
[...]
PHP 5.3.0RC1 (cli) (built: Apr 27 2009 11:12:36)What about CVS?
As I said, not sure if this is the way spl_autoload_register should
work withget_called_class()
.It works fine for me:
string(24) "Current class is: Loader"
string(22) "Calling Loader for Foo"
PHP Fatal error: Class 'Foo' not found in /usr/src/php/5.3/- on line 15-Hannes
--
Pablo Fischer (pablo [arroba/at] pablo.com.mx)
Hm, very strange, perhaps I'm building it with port (mac)?
$ sudo port install php5-devel
Don't know what this means.
Please try a normal CVS build:
$ cvs -d:pserver:cvsread@cvs.php.net/repository co -r PHP_5_3 php5
$ cd php5
$ ./buildconf && ./configure && make
$ sapi/cli/php /path/to/the/test/script.php
-Hannes
Hm, very strange, perhaps I'm building it with port (mac)?
$ sudo port install php5-devel
For issues in third party versions please contact the third party
distributor. Report issues to us only with versions from php.net /
snaps.php.net distributors tend to patch it and do other weird stuff we
don't know about.
johannes