PHP 解析错误:语法错误,意外的“?"在 helpers.php 233 [英] PHP Parse error: syntax error, unexpected '?' in helpers.php 233

查看:35
本文介绍了PHP 解析错误:语法错误,意外的“?"在 helpers.php 233的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我创建一个新的 Laravel 项目时,浏览器显示错误 500.我在日志中找到了这个:

When I create a new Laravel project, the browser displays an error 500. I found this in the log:

PHP 解析错误:语法错误,意外的?"在第 233 行的 vendor/laravel/framework/src/Illuminate/Foundation/helpers.php 中

PHP Parse error: syntax error, unexpected '?' in vendor/laravel/framework/src/Illuminate/Foundation/helpers.php on line 233

233中的代码是:

return app('cache')->get($arguments[0], $arguments[1] ?? null);

但据我所知,PHP 7.0 支持空合并运算符(??)

But as i know, null coalescing operator( ?? ) is supported from PHP 7.0

我的 PHP 版本:

PHP 7.1.8-2+ubuntu14.04.1+deb.sury.org+4 (cli) (build: Aug 4 2017 14:34:05) ( NTS )版权所有 (c) 1997-2017 PHP GroupZend Engine v3.1.0,版权所有 (c) 1998-2017 Zend Technologies使用 Zend OPcache v7.1.8-2+ubuntu14.04.1+deb.sury.org+4,版权所有 (c) 1999-2017,由 Zend Technologies 提供

PHP 7.1.8-2+ubuntu14.04.1+deb.sury.org+4 (cli) (built: Aug 4 2017 14:34:05) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.1.8-2+ubuntu14.04.1+deb.sury.org+4, Copyright (c) 1999-2017, by Zend Technologies

Laravel 版本:5.5.0

Laravel Version: 5.5.0

谁知道发生了什么?

推荐答案

如果非要我猜的话,我会说您仅将 PPA 7.1.8 安装为 CLI (php7-cli).您正在从中获取版本信息,但您的 libapache2-mod-php 包仍然是 14.04 main,即 5.6.在浏览器中检查您的 phpinfo 以确认版本.您也可以考虑迁移到 Ubuntu 16.04 以在主要版本中获得 PHP 7.0.

If I had to guess, I'd say you installed the PPA 7.1.8 as CLI only (php7-cli). You're getting your version info from that, but your libapache2-mod-php package is still 14.04 main which is 5.6. Check your phpinfo in your browser to confirm the version. You might also consider migrating to Ubuntu 16.04 to get PHP 7.0 in main.

这篇关于PHP 解析错误:语法错误,意外的“?"在 helpers.php 233的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆