[英]Parse error: syntax error, unexpected 'require' (T_REQUIRE), expecting identifier (T_STRING) in ComposerAPI.php on line 203
I'm willing to use the ComposerAPI ( https://github.com/kabachello/ComposerAPI ) Package for my Project. 我愿意为我的项目使用ComposerAPI ( https://github.com/kabachello/ComposerAPI )包。 But I got this error message with PHP 5.6
但是我用PHP 5.6得到了这个错误信息
Parse error: syntax error, unexpected 'require' (T_REQUIRE), expecting identifier (T_STRING) in ComposerAPI.php on line 203
解析错误:语法错误,意外'require'(T_REQUIRE),期望在第203行的ComposerAPI.php中的标识符(T_STRING)
With PHP 7.0 it's working fine. 使用PHP 7.0,它工作正常。 Can anybody help me ?
有谁能够帮助我 ?
Thanks. 谢谢。
The name of the function at this line is "require"
: 此行的函数名称为
"require"
:
public function require(array $package_names, array $options = null, OutputInterface $output = null){ }
PHP 5 doesn't allow to use reserved keyword as function name. PHP 5不允许使用保留关键字作为函数名。
As of PHP 7, the interpreter understands that is not the require()
function but a method of the class. 从PHP 7开始,解释器理解这不是
require()
函数,而是类的方法。
The Documentation said : 文件说 :
As of PHP 7.0.0 these keywords are allowed as property, constant, and method names of classes, interfaces and traits, except that class may not be used as constant name.
从PHP 7.0.0开始,这些关键字被允许作为类,接口和特征的属性,常量和方法名称,除了该类不能用作常量名称。
So, this code cannot be used with PHP before the version 7.0. 因此,在7.0版之前,此代码不能与PHP一起使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.