“use”关键字是否可用于函数闭包5.3之前? [英] Is the 'use' keyword available for function closures pre 5.3?

查看:232
本文介绍了“use”关键字是否可用于函数闭包5.3之前?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

地狱,我甚至不能找到在PHP网站上使用的文档(除了在命名空间的上下文 - 很好的工作模糊关键字BTW)。



有人可以确认 function()use($ foo){} 只在5.3及更高版本中可用吗?



作为一个额外的好处,你将如何编码不能使用'use'(eg:with create_function($ args, $ funcname)作为array_map()的回调?

解决方案


另外一个好处是可以在5.3或更高版本中使用 ,


我不能完全理解这个问题,因为两个闭包和使用和闭包都有相同的版本,没有情况,你不能使用 use 与封闭。 http://php.net/functions.anonymous



发行说明5.3.0


Hell, I can't even FIND the documentation for 'use' on the PHP site (other than in the context of namespaces - nice job ambiguating a keyword BTW).

Can someone confirm that function() use ($foo) { } is only available in 5.3 and later? And where did you find that documented?

As an added bonus, how would you code around not being able to use 'use' (eg: with create_function($args, $funcname) as the callback for array_map())?

解决方案

Closures are introduced in 5.3, thus use in conjunction with closures are also available in 5.3 or later (of course).

As an added bonus, how would you code around not being able to use 'use' within a closure

I don't understand the question completely, but because both closures and use with closures comes with the same version, there is no situation, where you can not use use with closures. Either both, or nothing (--> <5.3)

http://php.net/functions.anonymous

Release Notes 5.3.0

这篇关于“use”关键字是否可用于函数闭包5.3之前?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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