Anonymous functions are available from PHP 5.3.
Should I use them or avoid them? If so, how?
Edited; just found some nice trick with php anonymo
Anonymous functions can be very useful in creating function into DI container too, for example "bootstrap.php":
//add sessions
$di->add("session",function(){ return new Session(); });
//add cache
$di->add("cache",function(){ return new Cache(); });
//add class which will be used in any request
$di->add("anyTimeCalledClass", new SomeClass());
Example with usage params, and next variables
$di->add("myName",function($params) use($application){
$application->myMethod($params);
});
So here you can see how you can use anonymous functions to save memory and load of server. You can have defined all important plugins, classes in di container, but instances will be created just if you need it.