RE: [PHP] problem calling functions
| From: | Zoltán Németh | Date: | Sat, 20 Oct 2007 06:42:37 +0000 |
| Subject: | RE: [PHP] problem calling functions | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-263436@lists.php.net to get a copy of this message | ||
2007. 10. 19, péntek keltezéssel 11.33-kor Jay Blanchard ezt írta:
> [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).
why not?
http://www.php.net/manual/en/functions.variable-functions.php
greets
Zoltán Németh
> 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.....
> }
> }
>