Re: Calling functions which names are inside a variable

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

 



On Sat, 2007-08-25 at 23:46 -0600, Robert Keizer wrote:
> I am currently working on a module testing class, I can't seem to find the  
> correct syntax. Here is an example of the problem:
> 
> function foo( $var ){
> 	include $var.'.php';
> 	return $var(); // <!------- problem
> };
> 
> foo("somefunction");
> 
> In other words I am looking for a way to call a function by the value of a  
> variable. I get a Call to undefined method error,
> any help would be great..

You are calling the function correctly when using a variable. Namely:

    $var();

Check that the include file you want included is actually being
included. My guess is that it is not, or the function you expect to be
defined in it is not actually defined there.

Cheers,
Rob.
-- 
...........................................................
SwarmBuy.com - http://www.swarmbuy.com

    Leveraging the buying power of the masses!
...........................................................

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