Reputation: 43
Getting Function create_function() is deprecated Error in laravel 5.4 and php 7.2. Not able to find solution.
please see below code
public static function delimiterToCamelCase($string, $delimiter = '[\-\_]')
{
// php doesn't garbage collect functions created by create_function()
// so use a static variable to avoid adding a new function to memory
// every time this function is called.
static $callback = null;
if ($callback === null) {
$callback = create_function('$matches', 'return strtoupper($matches[1]);');
}
return preg_replace_callback('/' . $delimiter . '(\w)/', $callback, $string);
}
please help.
Upvotes: 1
Views: 924
Reputation: 364
create_function
has been deprecated as of php 7.2. Instead you can use anonymous_function.
if ($callback === null) {
$callback = function ($matches) {
return strtoupper($matches[1]);
};
}
Upvotes: 1