RE: problem calling functions

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

 



[snip]
 [snip]
<?php
function solution1($var1)    {
    // some code
}

function solution2($var2)    {
    // some code
}

function solution3($var3)    {
    // some code
}

if ($function == 'solution1' or $function == 'solution2' or $function ==
'solution3')
{
    $my_solution = $function($var); # this supposed to call one of
"solution" functions, right?
}
?>
[/snip]

I don't think you can put a function name in a variable and call it like
$function($var). You'd be better of with a case statement in one
function and call the proper solution (quick syntax, may need a little
fixing;

function my_solution($function, $var){
	switch $function{
	case function1:
		...do stuff...
	break;
	case function1:


		etc.....
	}
}
[/snip]

And call it like this;

my_solution('function1', $var);

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