Laravel parse error: syntax error, unexpected T

After installing laravel we get an error:

Parse error: syntax error, unexpected T_CLASS, expecting T_STRING or T_VARIABLE or '$' in C:xampphtdocslaravelpublicindex.php on line 50


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(IlluminateContractsHttpKernel::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


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

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.

链接地址: http://www.djcxy.com/p/11932.html

上一篇: 解析错误:语法错误,意外的T

下一篇: Laravel解析错误:语法错误,意外的T