You are here: Re: [PHP] How to call a function from $classname « PHP « IT news, forums, messages
Re: [PHP] How to call a function from $classname

Posted by Jochem Maas on 03/15/05 22:16

André Pletschette wrote:
> Thankyou,
>
> That works ;)
>
> Here the code:
> $get_table_fields_cmd = $classname."::intializeClass(\$dbConnect);";
> eval($get_table_fields_cmd);

welldone for figuring a way to do it! I have to tell you tho that eval()
is a very heavy function to use - my advice don't use it unless you have
to, and in this case you have a faster alternative:

$returnVal = call_user_func(array($classname, 'initializeClass'), $dbConnect);

see also return call_user_func_array() which offers more
flexible argument passing in cases where you may not know
exactly how many args have to be passed beforehand.

also note that you don't need the var $get_table_fields_cmd
(and notice the use of single quotes because no string interpolation
needs to be done):

eval($classname.'::intializeClass($dbConnect);');


>
> André
>
>
>
> François-Xavier Lacroix wrote:
>
>> Maybe With the eval() function ?
>>
>>> Hi,
>>>
>>> What do I have to do to call a function from $classname?
>>>
>>> Like: $classname->test( );
>>>
>>> Thankyou,
>>> André
>>>
>>
>
>

 

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

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