Original Question
Since a recent version of php added anonymous functions, is there a way to extend functions? in Javascript I'd do:
var temp = immaFunction;
immaFunction = function(){
//do some random stuff
temp.apply(this, arguments);
}
Result
As of 5.3, PHP has first class anonymous functions.
A few points to consider however(will be filling this with more as I mess around with it.):
- You must import any external variables you want to use. (Example 1)
Examples
Example 1:
$foo = "bar";
$fooBar = function() use ($foo){
echo $foo;
}
$fooBar(); //bar