Laravel parse error: syntax error, unexpected T_CL

2019-01-14 01:37发布

After installing laravel we get an error:

Parse error: syntax error, unexpected T_CLASS, expecting T_STRING or T_VARIABLE or '$' in C:\xampp\htdocs\laravel\public\index.php on line 50

标签: laravel-5
5条回答
干净又极端
2楼-- · 2019-01-14 01:45

Laravel 5.1 uses the ::class property to get string representations of a fully qualified classname. The error you're seeing is caused by this line

$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);

This language feature has been introduced in PHP 5.5 which is a requirement of Laravel 5.1. Your installed PHP version is probably older than 5.5. Try to update your PHP binary.


In case you are interested in why ::class is used, take a look at this answer

查看更多
Emotional °昔
3楼-- · 2019-01-14 01:51

Your PHP version on your Xampp is lower than 5.5.9 as specified in the Laravel 5.1 doc.

Simply uninstall your current Xampp software and download a fresh copy at Apache website with this specification 5.6.12 / PHP 5.6.12 .

Do not forget to collaborate with your host provider to ensure that your hosting account runs the required PHP version (>=5.5.9) during the deployment of your Laravel 5.1 app online.

查看更多
在下西门庆
4楼-- · 2019-01-14 01:53

Your php version is too low. Try version 7.0 or later php.

查看更多
仙女界的扛把子
5楼-- · 2019-01-14 01:55

Go to line 50 and check that there is a semi colon that terminates the code

查看更多
Lonely孤独者°
6楼-- · 2019-01-14 02:05

Same thing happened to me also. I found that web server was using my old PHP version 5. To solve it for me, I did this -

sudo a2dismod php5
sudo a2enmod php7.0
sudo service apache2 restart
查看更多
登录 后发表回答