Laravel 解析错误:语法错误,意外的 T_CLASS,期待 T_STRING 或 T_VARIABLE [英] Laravel parse error: syntax error, unexpected T_CLASS, expecting T_STRING or T_VARIABLE
问题描述
安装laravel后出现错误:
After installing laravel we get an error:
解析错误:语法错误,意外的 T_CLASS,在第 50 行的 C:xampphtdocslaravelpublicindex.php 中需要 T_STRING 或 T_VARIABLE 或 '$'
Parse error: syntax error, unexpected T_CLASS, expecting T_STRING or T_VARIABLE or '$' in C:xampphtdocslaravelpublicindex.php on line 50
推荐答案
Laravel 5.1 使用 ::class
属性 以获取完全限定类名的字符串表示形式.您看到的错误是由这一行引起的
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);
该语言特性已在 PHP 5.5 中引入,这是 Laravel 5.1 的要求.您安装的 PHP 版本可能早于 5.5.尝试更新您的 PHP 二进制文件.
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.
如果您对使用 ::class
的原因感兴趣,请查看这个答案
In case you are interested in why ::class
is used, take a look at this answer
这篇关于Laravel 解析错误:语法错误,意外的 T_CLASS,期待 T_STRING 或 T_VARIABLE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!