NYCPHP Meetup

NYPHP.org

[nycphp-talk] Getting Closure - on PHP Closures and 5.3

David Krings ramons at gmx.net
Sat Jul 17 07:54:26 EDT 2010


On 7/16/2010 22:57, John Campbell wrote:
> On Fri, Jul 16, 2010 at 10:21 PM, David Krings<ramons at gmx.net>  wrote:
>> Uhm, for the ones like me who have no clue what this means, any pointers
>> available that explain closures?
>
> You can read about closures until you are blue in the face.  The first
> thing you have to grock is first-class functions.  Which basically
> means a variable can be a function.  We normally think of variables as
> "data", but there is no reason you can't store a procedure in a
> variable.  Once you understand that functions are just another type of
> variable, then you can write functions that create other functions.
> e.g. you can return a function from a function.  The following code
> illustrates the concept, and is valid php 5.3

Ah, thanks for the hint. I know understand Hans' questions as well, such as 
why the heck would one want to use that? Then again, why not. Not using it is 
also valid php 5.3.

David



More information about the talk mailing list