简体   繁体   English

解析错误:语法错误,意外'require'(T_REQUIRE),期望在第203行的ComposerAPI.php中的标识符(T_STRING)

[英]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. 我愿意为我的项目使用ComposerAPIhttps://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.

相关问题 解析错误:语法错误,意外的'(',在第26行的-------------- / admin.php中期望T_STRING - Parse error: syntax error, unexpected '(', expecting T_STRING in --------------/admin.php on line 26 解析错误:语法错误,意外的“”“,期望”-“或标识符(T_STRING)或变量(T_VARIABLE)或数字(T_NUM_STRING)在PHP的第17行 - Parse error: syntax error, unexpected '"', expecting '-' or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) on line 17 in PHP 错误:(!)分析错误:语法错误,意外的''(T_ENCAPSED_AND_WHITESPACE),需要标识符(T_STRING) - Error : ( ! ) Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) Cakephp 解析错误:语法错误,意外的“类”(T_CLASS),需要标识符(T_STRING) - Cakephp Parse error: syntax error, unexpected 'Class' (T_CLASS), expecting identifier (T_STRING) 解析错误:语法错误,意外的“;”,需要标识符(T_STRING)或变量(T_VARIABLE) - Parse error: syntax error, unexpected ';', expecting identifier (T_STRING) or variable (T_VARIABLE) Wordpress-解析错误:语法错误,意外的“函数”(T_FUNCTION),期望的标识符(T_STRING) - Wordpress - Parse error: syntax error, unexpected 'function' (T_FUNCTION), expecting identifier (T_STRING) 解析错误:语法错误,意外的“ href”(T_STRING),期望为“,”或“;” - Parse error: syntax error, unexpected 'href' (T_STRING), expecting ',' or ';' PHP错误:“语法错误,意外的T_STRING,期望为','或';'” - PHP error: “syntax error, unexpected T_STRING, expecting ',' or ';'” 解析错误:语法错误,意外T_VARIABLE,期望PHP 5.3中的T_STRING - Parse error: syntax error, unexpected T_VARIABLE, expecting T_STRING in PHP 5.3 php解析错误:语法错误,意外的T_STRING,在构造上需要T_FUNCTION - php Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION on construct
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM