Thanks for article... Some of it is a bit over my head, but I get the general gist! One thing that has me confused is the usort example. Should this line: return ( $personA["age"] < $personB["age"] ) ? -1 : 1; Have "name" for $personA ? Cheers, Dave
You say "Note that, by this point, getGreetingFunction() has finished running. In normal circumstances, its local variable, $timeOfDay, would have fallen out of scope and disappeared. However, because we've created a closure using the anonymous function (now stored in $greetingFunction), the anonymous function can still access this $timeOfDay variable.".
I cant shake off the idea that $greetingFunction is a reference to getGreetingFunction(). You say getGreetingFunction has finished running but isnt it so that the named function is called every time the variable $greetingFunction is used? I cant get my head around the fact that the named function as well as the anonymous function runs whenever the variable is used (since it references the named function).