1

我的网站可以完美运行,localhost但是当移动到实时服务器时,Ubuntu 16.04 LTS我得到了这个错误

[2018 年 3 月 5 日星期一 11:11:28.968821] [:error] [pid 19322] [client 156.212.75.255:61635] PHP 解析错误:语法错误,意外 '?',期望变量 (T_VARIABLE) 在 XXXXXXXXXX/vendor/symfony /finder/Comparator/NumberComparator.php 在第 42 行 [Mon Mar 05 11:11:28.968895 2018] [:error] [pid 19322] [client 156.212.75.255:61635] PHP 致命错误:在 Unknown 中没有堆栈帧的情况下抛出异常在第 0 行 [Mon Mar 05 11:11:28.969374 2018] [:error] [pid 19322] [client 156.212.75.255:61635] PHP Parse error: syntax error, unexpected '?', Expecting variable (T_VARIABLE) in XXXXXXXXXX/ vendor/symfony/finder/Comparator/NumberComparator.php 在第 42 行 [Mon Mar 05 11:11:28.969390 2018] [:error] [pid 19322] [client 156.212.75.255:61635] PHP 致命错误:抛出没有堆栈的异常第 0 行的未知帧

我该如何解决这个问题以及删除公共目录的正确方法是什么?

4

4 回答 4

4

禁用php7.0

sudo a2dismod php7.0 

启用php7.1

sudo a2enmod php7.1 #to enable 7.1

重启阿帕奇

sudo service apache2 restart 
于 2018-05-02T13:26:52.253 回答
3

如果你看源代码

/**
 * @param string|int $test A comparison string or an integer
 *
 * @throws \InvalidArgumentException If the test is not understood
 */
public function __construct(?string $test)
{

?string它被称为Nullable类型。此功能出现在 php 之后7.1(请参阅此处的文档)。所以你需要在你的服务器上升级 php 版本。确保您获得最低 php 版本7.1。或使其与您的本地环境相同。

于 2018-03-05T11:27:23.463 回答
2

按照此链接将 php 版本升级到 7.2

https://thishosting.rocks/install-php-on-ubuntu/

然后运行此命令

须藤a2enmod php7.2 须藤a2dismod php7.0

sudo 服务 apache2 重启

于 2018-03-05T12:02:55.370 回答
1

检查您的 php 版本,很可能就是这样:

对于 ubuntu 家庭:

> a2dismod php5.6 #current version
> a2enmod php7.1 #required version ( 7.0, 7.1, 7.2 )
> service apache2 restart
于 2018-03-22T09:40:22.803 回答