PHP5 Static Object Function Issue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I believe there is  small problem in PHP5 with regard to static
functions in uninstanced classes.  From discussions in various php irc
channels and what I've read about it in the docs, I can not call a
static function in an uninstanced class via a variable.  For example:

 $class = "MyClass";
 $instance = new $class();

works, but

 $class = "MyClass";
 $instance = $class::getInstance();

doesnt, where

 $instance = MyClass::getInstance();

does.

I know that some people might consider it poor design, but basically
I'm trying to dynamically reference singleton patterned classes using
getInstance to internally create an object instance and use that
instance for all processing.  As of right now it doesn't seem that it
is possible.  Is there a reason why it's not supported?  Will it be
supported in the future?

Gavin

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux