Re: Redeclaring functions
| From: | Geoff Caplan | Date: | Fri, 11 Jan 2002 21:14:25 +0000 |
| Subject: | Re: Redeclaring functions | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-80344@lists.php.net to get a copy of this message | ||
Arve
PHP has variable function names:
$myfunc = "this_is_a_func" ;
$foo = $myfunc( ) ;
This way, you can make a single function call access a number of different
functions at run time. You can't change the declaration, but you can change
the call...
You don't really say what you are planning to do, but I would have thought
this approach should meet most requirements. I find it very useful.
Also, as I am sure you know, there are a number of ways of making the number
of parameters dynamic - probably the simplest is to standardise on a single
array as a param, and stick any values you need inside that.
I find that PHP is great for very late binding - there is usually a way if
you look for it...
Geoff Caplan
Advantae Ltd
> As a small, personal, "enjoy-myself"-project I'd like to run a
> perpetual-running socket server. Problem is; I also want it to be
> self-modifying so I can insert, remove and change functions as the
> server is running.
>
> The problem is; under normal circumstances, PHP won't let the script
> redeclare functions. Is there any way to circumvent this.
>