PHP Classes

call functions from variable

Recommend this page to a friend!

      Top level forums  >  PHP Specialists  >  General  >  call functions from variable  
Subject:call functions from variable
Summary:how do you call a function stored in a variable
Messages:3
Author:Jason
Date:2010-06-25 09:17:09
Update:2010-06-26 07:36:05
 

  1. call functions from variable   Reply   Report abuse  
Picture of Jason Jason - 2010-06-25 09:46:52
Hi All,

Here is the problem, I need to be able to call a function that is stored as a variable

i.e. $function = 'myFunction('arg1','arg2','arg3');

I have been playing with call_user_func and $function() but to no avail, the problem, (i think) is that the function will have a varying number or arguments depending on the function called.

if i break down the function into 2 parts:
$part1 = "myFunction";
$part2 = "'arg1','arg2','arg3'" // with or without brackets.

and then run $part1($part2);

I think its lokking at all 3 arguments as 1.

I hope that made some sense,

Thanks J.


There are 2 replies in this thread, which are not being displayed.
Browsing this forum thread replies is available only to premium subscribers.


Go to the premium subscriptions page to learn how to become a premium subscriber and have full access to this forum.