When was function use closures implemented in PHP? [duplicate]

风流意气都作罢 提交于 2019-12-02 23:33:22

问题


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.


回答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



来源:https://stackoverflow.com/questions/20411631/when-was-function-use-closures-implemented-in-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!