Calling a Function from name

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Johnlbuk
Forum Newbie
Posts: 19
Joined: Mon Sep 10, 2007 3:01 pm

Calling a Function from name

Post 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 :)
Last edited by Johnlbuk on Mon Apr 14, 2008 1:14 pm, edited 1 time in total.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Calling a Function

Post 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.
Johnlbuk
Forum Newbie
Posts: 19
Joined: Mon Sep 10, 2007 3:01 pm

Re: Calling a Function from name

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