Page 1 of 1

Calling a Function from name

Posted: Mon Apr 14, 2008 1:12 pm
by Johnlbuk
Hi,

I am trying to call a function. However, the name of the function comes from a get field which is then called.

Code: Select all

 $gateway = $_GET['gateway'];
 
$gateway_activate(); 
However, I just keep getting this error message below

Code: Select all

Fatal error: Call to undefined function: () in /****/******/configgateways.php on line 110
 
Can anyone shed some light on this?

Thanks,
John :)

Re: Calling a Function

Posted: Mon Apr 14, 2008 1:14 pm
by John Cartwright

Code: Select all

$funcname = $_GET['gateway'] .'_activate';
$funcname();
You cannot dynamically build the function name and execute it at the same time. Instead, build the name first.

Re: Calling a Function from name

Posted: Mon Apr 14, 2008 1:17 pm
by Johnlbuk
I am so stupid! I knew that, so not sure why I was trying to do that.
One of those moments!
Thanks for your help.

John