新的Laravel安装v 5.4 index.php引发解析错误。PHP 7.2.10-0ubuntu0.18.04.1

Ric*_*one 3 php apache2 laravel

在Ubuntu的Digital Ocean上安装了新的Laravel。当前的PhP安装。我添加了几行代码以吐出错误,Apache2可以很好地访问Php。这是输出:

解析错误:语法错误,第388行上的/var/www/html/blog/vendor/laravel/framework/src/Illuminate/Support/Arr.php中出现意外的'='

    public static function pluck($array, $value, $key = null)
{
    $results = [];
    [$value, $key] = static::explodePluckParameters($value, $key);
    foreach ($array as $item) {
        $itemValue = data_get($item, $value);
        // If the key is "null", we will just append the value to the array and keep
        // looping. Otherwise we will key the array using the value of the key we
        // received from the developer. Then we'll return the final array form.
        if (is_null($key)) {
            $results[] = $itemValue;
        } else {
            $itemKey = data_get($item, $key);
            if (is_object($itemKey) && method_exists($itemKey, '__toString')) {
                $itemKey = (string) $itemKey;
            }
            $results[$itemKey] = $itemValue;
        }
    }
    return $results;
}
Run Code Online (Sandbox Code Playgroud)

888行是:

[$value, $key] = static::explodePluckParameters($value, $key);
Run Code Online (Sandbox Code Playgroud)

当使用“ laravel new(站点名称)”创建新站点时,Laravel自动创建密钥。

服务器正在运行我的其他站点。我已经做了几个干净的Laravel安装,同样的问题。

Par*_*ras 5

发生这种情况是因为评估此脚本的PHP不是7.2版。该版本低于7.1。数组解构分配在7.1中引入-https: //wiki.php.net/rfc/short_list_syntax

您需要确定安装了哪些PHP版本,以及究竟哪个版本正在执行代码。