Page 1 of 1

class static call

Posted: Mon Nov 02, 2009 8:13 am
by pppswing
Hi,
I'd like to do a call :
$MyClass::$MyStaticFunction($param);

where $MyClass, $MyStaticFunction, $param are given parameters.

I tried with eval without success

eval($MyClass.'::'.$MyStaticFunction.'('.$param.');');

How can I do this call ?

Thanks :D

Re: class static call

Posted: Mon Nov 02, 2009 8:32 am
by guosheng1987
you may try to convert $myclass to string type

use echo to test the whole string.

Re: class static call

Posted: Mon Nov 02, 2009 8:39 am
by guosheng1987
echo $MyClass.'::'.$MyStaticFunction.'('.$param.');'
see what is it showed
examing the string and make sure that it can be execute.

Re: class static call

Posted: Mon Nov 02, 2009 8:59 am
by s1auk14
pppswing wrote:Hi,
I'd like to do a call :
$MyClass::$MyStaticFunction($param);

where $MyClass, $MyStaticFunction, $param are given parameters.

I tried with eval without success

eval($MyClass.'::'.$MyStaticFunction.'('.$param.');');

How can I do this call ?

Thanks :D
I think the way to call a static function should be $MyClass::MyStaticFunction($param);. Without the '$'.

Hope this can help.

Re: class static call

Posted: Mon Nov 02, 2009 10:20 am
by Mark Baker
call_user_func()