【问题标题】:PHP 5.6 to upgrade PHP 7 causes failed opening required include_path='.:/usr/local/php70/pearPHP 5.6 升级 PHP 7 导致打开失败需要 include_path='.:/usr/local/php70/pear
【发布时间】:2016-09-25 09:53:28
【问题描述】:

我们使用 PHP 5.6 开发了一个 WordPress/WooCommerce 网站,我们希望升级到 PHP7。该网站在 5.6 上完美运行,但在 PHP7 上运行会提高网站速度。

更改为 PHP7 导致以下 500 错误:

PHP 致命错误:require_once(): Failed opening required '' (include_path='.:/usr/local/php70/pear') 在 /home/servername/public_html/customer/customername/wp-content/themes/flux/framework/qode-framework.php 在第 4 行

我们在另一个主机的另一个 PHP7 服务器上使用该站点的副本进行了快速测试,PHP7 工作正常。所以应该是服务器设置,但我想不通。

如果有人能帮助我理解这个问题,那就太好了!

谢谢

【问题讨论】:

  • 参见qode-framework.php 第 4 行,包含的文件路径错误。替换为函数require_once()中的正确文件路径。
  • @AHJeebon 感谢您的反馈。在第 4 行的qode-framework.php 中,它声明require_once("lib/qode.framework.php"); 文件就在那里。相对路径名可能有问题吗?在stackoverflow的某个地方,我读到了一个类似的错误,它与错误的根有关。我可以包含绝对路径名吗?
  • 使用相对路径:require_once(dirname(__FILE__).'/**here write your relative path, if back directory then use (../)**');
  • 感谢您的努力。我实施了您的建议,但错误仍然相似。所需打开失败从 ' ' 到 '%': PHP Fatal error: require_once(): Failed opening required '%' (include_path='.:/usr/local/php70/pear') in /home/servername/public_html/customer/customername/wp-content/themes/flux/framework/qode-framework.php on line 4
  • 我的主机有类似的问题,我的应用程序使用 php 5.6 工作文件,但是当我切换到 php 7、7.2、7.4 时,我会得到 'include_path='.:/usr/local/php70 /pear ' 每个版本的php都有错误,所以我认为是php版本的问题,我还在寻找解决方案。

标签: php wordpress


【解决方案1】:

转到第 4 行的 /home/servername/public_html/customer/customername/wp-content/themes/flux/framework/qode-framework.php 文件,并执行以下代码示例:

require_once(realpath(__DIR__.'/../vendor/autoload.php'));

require_once(realpath(__DIR__.'/../your-file-path'));

require_once(realpath(__DIR__.'/your-file-path'));

确保使用realpath(), this command will convert a relative path to an absolute one

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-06-29
    • 2017-07-16
    • 1970-01-01
    • 2014-03-05
    • 2018-02-22
    • 2023-03-20
    • 2016-10-05
    • 2018-05-27
    相关资源
    最近更新 更多