【问题标题】:PHP use keyword is causing 500 server errorPHP使用关键字导致500服务器错误
【发布时间】:2017-09-29 19:05:13
【问题描述】:

我正在尝试实现 PhpPresentation 来转换一些文件,所以我有以下代码:

use PhpOffice\PhpPresentation\src\PhpPresentation\PhpPresentation;
use PhpOffice\PhpPresentation\src\PhpPresentation\IOFactory;
use PhpOffice\PhpPresentation\src\PhpPresentation\Style\Color;
use PhpOffice\PhpPresentation\src\PhpPresentation\Style\Alignment;

由于某种原因,这段代码确实导致了 500 Internal server error。我将错误报告设置为全部,但没有显示错误。路径是对的,我的根目录(public_html)中有 PhpOffice 文件夹和相应的子文件夹。

自动加载器代码是这样加载的:

require_once 'PhpOffice/PhpPresentation/src/PhpPresentation/Autoloader.php';
  \PhpOffice\PhpPresentation\Autoloader::register();
  require_once 'PhpOffice/src/Common/Autoloader.php';
  \PhpOffice\Common\Autoloader::register();

【问题讨论】:

  • 查看您的 http 服务器错误日志文件,您可以在其中阅读实际问题。
  • 您的自动装载机很可能找不到这些定义。
  • syntax error, unexpected 'use' 在第一个使用行。这是我的全部功能codeshare.io/aYAdzL
  • 一些想法:use 行之前是否有任何行?也许一个缺少;?只是为了确定......你的 PHP 版本是什么?
  • 好的,这意味着您的 php 版本很可能已经过时并且低于5.6。你想升级。

标签: php namespaces


【解决方案1】:

问题已解决,感谢https://stackoverflow.com/a/33355711/7926703

我在一个错误且导致错误的函数中使用了“use”。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-10
    • 1970-01-01
    • 1970-01-01
    • 2023-03-22
    • 2015-11-23
    相关资源
    最近更新 更多