用php8的其他东西替换create_function()

发布于 2025-02-11 16:58:35 字数 533 浏览 2 评论 0原文

因此,我有一个以前工作正常的插件,但是几天后,它给我带来了一个错误:

php致命错误:未定的错误:致电未定义的函数create_function()

后,我发现这是因为create_function()

搜索 问题是:

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

我尝试将其更改为:

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

但是它不起作用。因此,如果有人可以将我指向正确的方向,我也是PHP的新手,那就太好了。

So I have a plugin that was working fine previously, but for a few days now it is throwing me an error as:

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

After a bit of searching, I found out that this is because create_function() is deprecated in PHP 8.

Now the exact line that causes the issue is this:

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

I tried changing this to:

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

But it's not working. So it would be great if someone could point me in the right direction also I am very new to PHP.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独享拥抱 2025-02-18 16:58:36

尝试

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

Try

$callback_2 = function($matches) {
    return "[" . str_replace("|", "", $matches[1]) . "]";
};
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文