Jump to content

Call a function with parameters stored within a variable as a String.


tmh766

Recommended Posts

Is this possible?

 

For example

 

$variable="functionOne('param1','param2')";

 

Another example

 

$varaible2="functionOne(functionTwo(1))";

 

Is it possible to execute $variable which would then call functionOne and pass it its parameters? And is it possible to execute $variable2 which would call functionOne which would call functionTwo?

Here's another basic example:

 

function f1($var1){
   $what = $var1;
   return $what;
}

function f2($var2){
   $what2 = $var2 + 2;
   return $what2;
}

$variable = f1(f2(1));
echo $variable;

?>

 

As long as f2 returns something it will pass it to f1 which returns $what and variable is assigned to it.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.