Returning a value from an anonymous function

Star Trek's Mr. Spock

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:


Of course, the Drupal Community isn't the only place to give back. It's a complex world, and there are as many worthy causes as their are melodies, with most being served by multiple charitable organizations. Here are a few of those that strike a 7th chord with me.