Anonymous functions pre PHP 5.3.0

六眼飞鱼酱① 提交于 2019-11-27 08:03:27

问题


Is there an alternative to anonymous functions in versions of PHP previous to 5.3.0?


回答1:


There is create_function but it generally isn't recommended. If you're using OOP, you'd be better off defining a one-off private member to use with a callback instead.




回答2:


Yes, create_function()




回答3:


There are two choices.

First is to create a function, inside a function. Unfortunately, it will pollute the global namespace.

The second choice is to use create_function.



来源:https://stackoverflow.com/questions/3694620/anonymous-functions-pre-php-5-3-0

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