调用未定义的函数create_function。

16

我尝试启用一个已安装的插件,但出现了以下错误。我无法再次打开网站。我重启了计算机并加载了本地主机URL,仍然遇到下面相同的错误:

致命错误:未捕获的错误:在C:\xampp\htdocs\university\wp-content\plugins\full-site-builder-for-elementor\extensions\google-maps\google-maps.php的第136行调用未定义的函数create_function():136

堆栈跟踪: #0 C:\xampp\htdocs\university\wp-content\plugins\full-site-builder-for-elementor\extensions\google-maps\google-maps.php(441):stylepress_dtbaker_Shortcode_Google_Map -> init() #1 C:\xampp\htdocs\university\wp-content\plugins\full-site-builder-for-elementor\inc\class.plugin.php(184):require_once('C:\ xampp \ htdocs ...')#2 C:\xampp\htdocs\university\wp-includes\class-wp-hook.php(307):DtbakerElementorManager -> load_extensions('')#3 C:\xampp\htdocs\university\wp-includes\class-wp-hook.php(331):WP_Hook -> apply_filters(NULL,Array)#4 C:\xampp\htdocs\university\wp-includes\plugin.php(476):WP_Hook -> do_action(Array)#5 C:\xampp\htdocs\university\wp-settings.php(598):do_action('init')#6 C:\xampp\htdocs\university\wp-config.php(96):require_once('C:\ xampp \ htdocs ...')#7 C:\xampp\htdocs\university\wp-load.php(50):require_once('C:\ xampp \ htdocs ...')#8 C:\xampp\htdocs\university\wp-blog-header.php(13):require_once('C:\ xampp \ htdocs ...')#9 C:\xampp\htdocs\university\index.php(17):require('C:\ xampp \ htdocs ...')#10 {main} 抛出在C:\xampp\htdocs\university\wp-content\plugins\full-site-builder-for-elementor\extensions\google-maps\google-maps.php的第136行。


1
看起来你正在使用的插件与 PHP 8 不兼容(参见 create_function())。或者至少该插件的那个版本不兼容。你尝试过联系开发者了吗?如果没有,请联系他们并寻求帮助。 - cabrerahector
1
这个回答解决了你的问题吗?PHP 7.2函数create_function()已被弃用 - Howard E
请提供足够的代码,以便他人更好地理解或重现问题。 - Community
3个回答

6

对于你具体的使用情况我很难进行故障排除,但是以下一些笔记和工具可能会帮助你解密并修复此问题。错误是由于你在PHP8上运行,但你的代码具有PHP7不兼容性。

A.) 要么将服务器降级到PHP7 B.) 或者更新扩展以适应PHP8 C.) 或手动更新扩展。

已弃用的create_function() > PHP7需要替换为匿名的PHP8函数调用。

更多信息: 请参见:PHP 7.2 Function create_function() is deprecated 和:https://www.php.net/manual/en/function.create-function.php

如果你想深入到代码本身去修复这个问题:

  1. 下载Notepad++ https://notepad-plus-plus.org/
  2. 在你的代码编辑器中打开此文档:C:\xampp\htdocs\university\wp-content\plugins\full-site-builder-for-elementor\extensions\google-maps\google-maps.php
  3. 转到:第136行
  4. 使用上述笔记并尝试使用这些笔记重写该函数。

你可能会在代码中遇到其他弃用的函数:

  1. 转到搜索->文件中查找(Ctrl+Shift+F)搜索文档 C:\xampp\htdocs\university\wp-content\plugins\full-site-builder-for-elementor\extensions\,寻找 "create_function("
  2. 这些被弃用的函数实例需要更新,以使你的错误消失。
  3. 请注意:在此扩展中,可能会出现其他类型的弃用代码错误。最好不要尝试单独修复这些问题,除非你没有其他选项,比如升级或降级PHP版本。

4

1
当我使用PHP 8.x时,也遇到了这样的错误消息。解决方法是使用PHP 7.4。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接