开发者

Anonymous functions pre PHP 5.3.0

开发者 https://www.devze.com 2023-01-15 15:23 出处:网络
Is there an alternative to anonymous functions in versions of PHP previous to 开发者_StackOverflow社区5.3.0?There is create_function but it generally isn\'t recommended. If you\'re using OOP, you\'d b

Is there an alternative to anonymous functions in versions of PHP previous to 开发者_StackOverflow社区5.3.0?


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.


Yes, create_function()


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消