Laravel 6: 无法在服务器上 运行 任何 artisan 命令

Laravel 6: Cannot run any artisan command on the server

[更新]

像这样编辑 artisan 文件

ini_set('display_errors',1);
error_reporting(-1);

我遇到了这个错误

Parse error: syntax error, unexpected '?' in /home/u635130117/domains/example.com/public_html/laravel/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php on line 500

这是代码

if (isset($arguments[1]) && is_string($arguments[1])) {
        return $factory->of($arguments[0], $arguments[1])->times($arguments[2] ?? null); //line 500
    } elseif (isset($arguments[1])) {
        return $factory->of($arguments[0])->times($arguments[1]);
    }

我已使用 SSH 连接到共享主机,但不能 运行 任何 artisan 命令,如清除缓存或列出 artisan 命令,我什么也得不到,没有输出。我测试了创建一个新命令,但它也没有创建。

php版本过低会出现解析错误。所以我们发现 php -v 执行后返回 php 版本 5.6.40.

服务器上安装了多个版本的 php

最后在 phpinfo 中是 php 7 版本的路径,它也被网络服务器使用。这是 /opt/alt/php72/usr/bin/php

现在可以使用 /opt/alt/php72/usr/bin/php 执行命令,例如 /opt/alt/php72/usr/bin/php artisan key:generate

您还可以为此创建一个别名,如 php7php。它被描述为 here