PHP 7.2 Function create_function() is deprecated

前端 未结 4 1263
庸人自扰
庸人自扰 2020-11-22 07:18

I have used create_function in my application below.

$callbacks[$delimiter] = create_function(\'$matches\', \"return \'$delimiter\' . strtolower(\\$matches[1         


        
4条回答
  •  说谎
    说谎 (楼主)
    2020-11-22 08:01

    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]);
    };
    

提交回复
热议问题