Re: Are there plans to allow anonymous functions as callbacks?

From: Date: Wed, 04 Mar 2009 12:40:05 +0000
Subject: Re: Are there plans to allow anonymous functions as callbacks?
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-43244@lists.php.net to get a copy of this message
2009/3/4 Olivier B. <php-dev.list@daevel.net>: > > Alexey Zakhlestin a écrit : >> >> On Wed, Mar 4, 2009 at 2:33 PM, Richard Quadling >> <rquadling@googlemail.com> wrote: >> >>> >>> Hi. >>> >>> Quite a simple question (assuming I've got the terminology correct). >>> >>> Are there any plans to allow code like this (amended example taken >>> from the array_map() documentation) ... >>> >>> <?php >>> $a = array(1, 2, 3, 4, 5); >>> $b = array_map(function($n){return($n * $n * $n)}, $a); >>> print_r($b); >>> >>> For me, this is cleaner than having a use-once, namespace-polluting >>> function. >>> >>> Currently, this is producing a parse error. >>> >> >> It works. You have a typo. You need to put ";" after return (…) >> Just shoot me now! >> > > Hi, > > with PHP < 5.3, you can also use create_function() > (http://www.php.net/create_function ) > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!"

« previous php.internals (#43244) next »