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

查看:353
本文介绍了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)(内置:2017年8月4日14:34:05)(NTS) 版权所有(c)1997-2017 The PHP Group Zend Engine v3.1.0,版权所有(c)1998-2017 Zend Technologies 与Zend OPcache v7.1.8-2 + ubuntu14.04.1 + deb.sury.org + 4,Zend Technologies版权所有(c)1999-2017

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以获得Main的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天全站免登陆