PHP 7.2 Function Create_Function() Is Deprecated

PHP 7.2 Function create_function() is deprecated

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 error Function create_function() is deprecated

Should be as simple as replacing the function call with an anonymous function.

usort($languages, function($a, $b) {
if($a[0] == $b[0]) {
return 0;
}
return $a[0] < $b[0] ? 1 : -1;
});

Need help converting deprecated Function create_function() in PHP 7.2

You can use an anonymous function.

array_walk($_REQUEST['categories'], function(&$c) { $c = "-" . $c; });

Example

$array = ['a','b','c'];
array_walk($array, function(&$c) { $c = "-" . $c; });
print_r($array);

Will produce

Array
(
[0] => -a
[1] => -b
[2] => -c
)

Function create_function() is deprecated in php7.2

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


Related Topics



Leave a reply



Submit