Re: How to call a function from $classname

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

 



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é





-- 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