You are here: Re: Accessing constant and static members of a class name held in a variable « PHP Programming Language « IT news, forums, messages
Re: Accessing constant and static members of a class name held in a variable

Posted by Rafe Culpin on 10/06/60 11:41

In article <1141401380.714474.101750@v46g2000cwv.googlegroups.com>,
zeldorblat@gmail.com (ZeldorBlat) wrote:

> You can get to them using call_user_func() and constant() like this:
>
> class foo {
> const BAR = 5;
> public static function baz() {
> //do something static
> }
> }
>
> $myClassName = 'foo';
> $bar = constant($myClassName . '::BAR');
> $z = call_user_func(array($myClassName, 'baz'));

Aha! That works great - many thanks.

Seems odd they haven't made it simpler to do. Maybe in the next version.

--
To reply email rafe, at the address cix co uk

 

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

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