作为类名部分无效的PHP关键字列表
我正在为PHP5.2转换一些用“穷人的名称空间”编写的旧代码,就像这样 类Foo_Bar_Model_Break_Baz{} 我将此代码转换为一个新系统,该系统需要真实的名称空间,如下所示作为类名部分无效的PHP关键字列表,php,parsing,namespaces,Php,Parsing,Namespaces,我正在为PHP5.2转换一些用“穷人的名称空间”编写的旧代码,就像这样 类Foo_Bar_Model_Break_Baz{} 我将此代码转换为一个新系统,该系统需要真实的名称空间,如下所示 namespace Foo\Bar\Model\Break; class Baz { } 不幸的是,PHP解析器无法处理上述类,因为Break是一个保留字 Parse error: syntax error, unexpected 'Break' (T_BREAK), expecting identifie
namespace Foo\Bar\Model\Break;
class Baz
{
}
不幸的是,PHP解析器无法处理上述类,因为Break
是一个保留字
Parse error: syntax error, unexpected 'Break' (T_BREAK), expecting identifier (T_STRING) in
作为PHP完整类名/命名空间的一部分,是否有哪些解析器标记无效的列表?最初的一些谷歌搜索和php.net没有显示任何内容,但我可能使用了错误的搜索词 在PHP7中,随着添加了。此RFC将保留关键字的数量从64个减少到1个,其中一个是名为
class
(不区分大小写)的类常量
引用RFC,PHP中的全局保留关键字列表?
callable class trait extends implements static abstract final public
protected private const enddeclare endfor endforeach endif endwhile and
global goto instanceof insteadof interface namespace new or xor try
use var exit list clone include include_once throw array print echo
require require_once return else elseif default break continue switch
yield function if endswitch finally for foreach declare case do while
as catch die self parent