【发布时间】: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