php - 新的 Laravel install v 5.4 index.php 抛出解析错误。PHP 7.2.10-0ubuntu0.18.04.1
问题描述
在 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;
}
第 888 行是:
[$value, $key] = static::explodePluckParameters($value, $key);
Laravel 在使用“laravel new(站点名称)”创建新站点时会自动创建一个密钥
服务器运行我的其他网站就好了。我已经完成了几次干净的 Laravel 安装,同样的问题。
解决方案
发生这种情况是因为评估此脚本的 PHP 不是 7.2 版。它是低于 7.1 的版本。7.1 中引入了数组解构赋值 - https://wiki.php.net/rfc/short_list_syntax
您需要弄清楚安装了哪些 PHP 版本以及执行代码的确切版本。
推荐阅读
- angular - 重置 Angular Reactive FormArray 值
- ios - 如何为 collectionviewcell 内的进度条创建 IBOutlet?
- javascript - 用javascript压缩二维数组的重复
- sql - 如何计算 Microsoft SQL Server 中所有 ID 的日期差异
- c# - Log4net 在调试时没有将任何数据记录到文件中
- python - 滚动文本python更改ceratin背景文本
- javascript - 加载的 HTML 下拉菜单已识别所选字段,但未识别值字段?
- python - 如何使用 mxnet 的数据集对象在整个测试集上测试神经网络?
- javascript - 单击后取消选中问卷单选按钮
- python - 使用 TPOT CV 拟合时,是否在整个数据集上重新训练了 fit_pipeline_?