不推荐使用PHP 7.2函数create_function() [英] PHP 7.2 Function create_function() is deprecated
本文介绍了不推荐使用PHP 7.2函数create_function()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在下面的应用程序中使用过create_function.
I have used create_function in my application below.
$callbacks[$delimiter] = create_function('$matches', "return '$delimiter' . strtolower(\$matches[1]);");
但是对于PHP 7.2.0,不建议使用create_function().
But for PHP 7.2.0, the create_function() is deprecated.
任何想法,如何在PHP 7.2.0上修复我的代码.
Any idea, how to fix my codes above on PHP 7.2.0.
感谢您的帮助,
推荐答案
You should be able to use an Anonymous Function (aka Closure) with a call to the parent scoped $delimiter
variable, like so:
$callbacks[$delimiter] = function($matches) use ($delimiter) {
return $delimiter . strtolower($matches[1]);
};
这篇关于不推荐使用PHP 7.2函数create_function()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文