e.g.:
$functions = array(
'function1' => function($echo) { echo $echo; }
);
Is this possible? What's the best alternative?
|
There are a few options. Use
Simply store the function's name as a string (this is effectively all
If you are using PHP 5.3 you can make use of anonymous functions:
All of these methods are listed in the documentation under the
|
|||||||
|
A better answer might be a question as to why you are putting functions in arrays. Depending on what you're trying to accomplish, this may not be the best use of your code. edit: here's a good way to declare and use php functions: (at the top of the page)
(in your code)
:) Nice and clean. If you need something more structured than that, you should really look into objects.
|
|||||||
|