Re: dynamically selecting a function
| From: | Burhan Khalid | Date: | Mon, 08 Aug 2005 09:24:37 +0000 |
| Subject: | Re: dynamically selecting a function | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-220205@lists.php.net to get a copy of this message | ||
Thomas wrote:
Hi there, How can I do something like this: [snip - theoretical code] if( isset($step) ) echo step.$step() ) [/snip] $step would be an int (I would check that before) and then I would have all sorts of functions like step1(), step2() . etc.Use call_user_func(). Simple example: function x1() { print 'x1'; } function x2() { print 'x2'; } $x = 1; call_user_func('x'.$x); $x = 2; call_user_func('x'.$x);