Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.7k views
in Technique[技术] by (71.8m points)

laravel 5.5 - PHP Parse error: syntax error, unexpected '?' in helpers.php 233

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

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

the code in 233 is:

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

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

My PHP Version:

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 Version: 5.5.0

Who knows what happened?

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...