新 Laravel 安装 v 5.4 index.php 抛出解析错误。 PHP7.2.10-0ubuntu0.18.04.1
New Laravel install v 5.4 index.php throwing parsing error. PHP 7.2.10-0ubuntu0.18.04.1
Digital Ocean 上的新 Laravel 安装,Ubuntu。当前 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;
}
第 888 行是:
[$value, $key] = static::explodePluckParameters($value, $key);
Laravel 在使用 "laravel new (site name)"
创建新站点时自动创建密钥
服务器是运行我的其他网站就好了。我已经完成了几次干净的 Laravel 安装,同样的问题。
发生这种情况是因为正在评估此脚本的 PHP 不是 7.2 版。它是低于 7.1 的版本。 7.1 中引入了数组解构赋值 - https://wiki.php.net/rfc/short_list_syntax
您需要弄清楚安装了哪些 PHP 版本以及哪个版本正在执行代码。
希望这对某人有所帮助。所以你需要做的是去 /etc/apache2/mods-enabled ls-l 看看加载了什么 php 版本。 "sudo a2dismod php7.0" 禁用 php7.0 mod 并使用 "sudo a2enmod php7.2"。使用 "systemctl restart apache2" 重新启动 apache2,你应该没问题。
Digital Ocean 上的新 Laravel 安装,Ubuntu。当前 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;
}
第 888 行是:
[$value, $key] = static::explodePluckParameters($value, $key);
Laravel 在使用 "laravel new (site name)"
创建新站点时自动创建密钥服务器是运行我的其他网站就好了。我已经完成了几次干净的 Laravel 安装,同样的问题。
发生这种情况是因为正在评估此脚本的 PHP 不是 7.2 版。它是低于 7.1 的版本。 7.1 中引入了数组解构赋值 - https://wiki.php.net/rfc/short_list_syntax
您需要弄清楚安装了哪些 PHP 版本以及哪个版本正在执行代码。
希望这对某人有所帮助。所以你需要做的是去 /etc/apache2/mods-enabled ls-l 看看加载了什么 php 版本。 "sudo a2dismod php7.0" 禁用 php7.0 mod 并使用 "sudo a2enmod php7.2"。使用 "systemctl restart apache2" 重新启动 apache2,你应该没问题。