0

I couldn't find the section in the PHP manual that explains use

I have the code

$num = 0;
array_walk_recursive($_REQUEST, function($mValue) use (&$num){
           $num++;
        });

and my Eclipse complains:

Parser error "'{' expected in compound-statement.

So I guess this was implemented in some PHP version.

rubo77
  • 19,527
  • 31
  • 134
  • 226
  • "I couldn't find the section in the PHP manual that explains use" --- have you checked an anonymous function reference page? – zerkms Dec 05 '13 at 22:00
  • See also http://www.php.net/manual/en/functions.anonymous.php#~Changelog – mario Dec 05 '13 at 22:00
  • @mario: that's interesting - what `#~Changelog` means? – zerkms Dec 05 '13 at 22:03
  • 1
    @zerkms It's a text search anchor; very much *non-standardized*. There were some whatwg discussions on such features, which however didn't go anywhere. So I made a [userscript](http://userscripts.org/scripts/show/119759). – mario Dec 05 '13 at 22:10

1 Answers1

1

Anonymous functions/closures and the use language construct were implemented in version 5.3.0

@see changelog: http://php.net/manual/en/functions.anonymous.php

Darragh Enright
  • 13,676
  • 7
  • 41
  • 48