哪个版本的php添加了匿名功能 [英] Which version of php added anonymous functions

查看:61
本文介绍了哪个版本的php添加了匿名功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在手册中有create_function函数,您可以将结果从该函数传递给array_map,我认为这是拥有类似匿名函数和闭包之类的唯一方法,但是后来我发现我可以放功能类似于javascript

In manual there is create_function function and you can pass result from that function to array_map, I thought that that is the only way to have something like anonymous functions and closures, but then I found that I can just put function like in javascript

array_map(function($a) {
    return $a + 1;
}, array(1, 2, 3, 4, 5));

我可以在哪个版本的php中执行此操作?这总是在那里吗?

In which version of php I can do this? Was this always there?

推荐答案

在PHP中添加了闭包(匿名函数) 5.3.0

Closures (anonymous functions) were added in PHP 5.3.0

这篇关于哪个版本的php添加了匿名功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆