0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Parse error: syntax error, unexpected '?'はPHPのバージョンを直して解決

Posted at

環境

  • Laravel5.5
  • Ubuntu 16.04

Ubuntuの場合、PHPのバージョンによって、エラーが起こるらしい。

PHPのバージョンが低いのが問題

PHPをローカル環境で開発していた(動いていた当時)のものに変更する。
僕の場合はPHP7.1に変更必要があった。

PHP version確認

php -v

あれ、7.1だ...

表示されるものと、Laravelの駆動に使われるPHPのバージョンが違う

welcome.blade.phpなどに、phpinfo()を表示してみよう。

welcome.blade.phpの

の真下辺りにphpinfo()を出力させる
welcome.blade.php
...
<body>
 <?php phpinfo(); ?>
...
</html>

これで、表示を見る。

実際のPHPのバージョンを確認

僕の場合は、7.0でした。惜しい!
php.iniの場所などがかいてあるので、そのディレクトリから判断しましょう。

不要なバージョンは消そう。

sudo a2dismod php7.0
sudo a2enmod php7.1
sudo service apache2 restart

お使いの環境に合わせてどうぞ。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?