Returning a value from an anonymous function

Anonymous functions were added to php in version 5.3, and are most often used for assigining a function to a variable to be used later as a callback. They also are useful for declaring limited-use or one-time-use functions without declaring them in the global space.

Sometimes it is desired to receive a value BACK from an anonymous function, and how to do that is not intuitive.

First, let's look at how it works with a typical function:

 

©2005-2017 Ayen Designs. Underlying theme by Kiwi Themes.