Replace create_function() with something else for PHP8
P粉197639753
P粉197639753 2023-10-25 20:35:09
0
1
680

So I have a plugin that used to work fine, but for a few days it threw me an error:

PHP Fatal Error: Uncaught Error: Call to undefined function create_function()

After some searching, I found out that this is because create_function() has been deprecated in PHP 8.

Now the exact line causing the problem is:

$callback_2 = create_function('$matches', 'return "[" . str_replace("|", "", $matches[1]) . "]";');

I tried changing it to:

$callback_2 = function(){
 ('$matches', return "[" . str_replace("|", "", $matches[1]) . "]";);
}

But it doesn't work. So if anyone could point me in the right direction, and I'm new to PHP, that would be great.

P粉197639753
P粉197639753

reply all(1)
P粉771233336

try

$callback_2 = function($matches) {
    return "[" . str_replace("|", "", $matches[1]) . "]";
};
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template