You are here: Re: [PHP] calling static methods of variable class names « PHP « IT news, forums, messages
Re: [PHP] calling static methods of variable class names

Posted by Jochem Maas on 11/22/05 15:52

Ahmed Saad wrote:
> hi all,
>
> how can i call static methods of a class whose name is variable.. something like
> <? $className::doSomething(); // throws a parser error ?>
> I can do this with reflection by creating a ReflectionMethod object
> then invoke()ing it, but is there a better way?

try call_user_func() and/or call_user_func_array()

e.g.

call_user_func( array($className, 'doSomething') );

the array passed in this case is how one tells php the callback
function you are handing it is a class+method, you can also use this
callback notation to pass in an object+method.

> Thanks
>
> -ahmed

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация