附录 P. 解析器代号列表

PHP 语言的不同部分在内部被表示为类似 T_SR 的类型。PHP 在解析错误时输出这样的标识符,例如 "Parse error: unexpected T_SR, expecting ',' or ';' in script.php on line 10."

你应该知道 T_SR 的含义。对于所有不知道的人,这里有一张表列出了这些标识符,PHP 语法和在手册中适当位置的参考。

表格 P-1. 代号

代号语法参考
T_AND_EQUAL&=assignment operators
T_ARRAYarray()array(), array syntax
T_ARRAY_CAST(array)type-casting
T_ASasforeach
T_BAD_CHARACTER anything below ASCII 32 except \t (0x09), \n (0x0a) and \r (0x0d)
T_BOOLEAN_AND&&logical operators
T_BOOLEAN_OR||logical operators
T_BOOL_CAST(bool) or (boolean)type-casting
T_BREAKbreakbreak
T_CASEcaseswitch
T_CHARACTER  
T_CLASSclassclasses and objects
T_CLOSE_TAG?> or %> 
T_COMMENT// or #comments
T_CONCAT_EQUAL.=assignment operators
T_CONSTconst 
T_CONSTANT_ENCAPSED_STRING"foo" or 'bar'string syntax
T_CONTINUEcontinue 
T_CURLY_OPEN  
T_DEC--incrementing/decrementing operators
T_DECLAREdeclaredeclare
T_DEFAULTdefaultswitch
T_DIV_EQUAL/=assignment operators
T_DNUMBER0.12, etcfloating point numbers
T_DOdodo..while
T_DOLLAR_OPEN_CURLY_BRACES${complex variable parsed syntax
T_DOUBLE_ARROW=>array syntax
T_DOUBLE_CAST(real), (double) or (float)type-casting
T_ECHOechoecho()
T_ELSEelseelse
T_ELSEIFelseifelseif
T_EMPTYemptyempty()
T_ENCAPSED_AND_WHITESPACE  
T_ENDDECLAREenddeclaredeclare, alternative syntax
T_ENDFORendforfor, alternative syntax
T_ENDFOREACHendforeachforeach, alternative syntax
T_ENDIFendifif, alternative syntax
T_ENDSWITCHendswitchswitch, alternative syntax
T_ENDWHILEendwhilewhile, alternative syntax
T_END_HEREDOC heredoc syntax
T_EVALeval()eval()
T_EXITexit or dieexit(), die()
T_EXTENDSextendsextends, classes and objects
T_FILE__FILE__constants
T_FORforfor
T_FOREACHforeachforeach
T_FUNCTIONfunction or cfunctionfunctions
T_GLOBALglobalvariable scope
T_IFifif
T_INC++incrementing/decrementing operators
T_INCLUDEinclude()include()
T_INCLUDE_ONCEinclude_once()include_once()
T_INLINE_HTML  
T_INT_CAST(int) or (integer)type-casting
T_ISSETisset()isset()
T_IS_EQUAL==comparison operators
T_IS_GREATER_OR_EQUAL>=comparison operators
T_IS_IDENTICAL===comparison operators
T_IS_NOT_EQUAL!= or <>comparison operators
T_IS_NOT_IDENTICAL!==comparison operators
T_SMALLER_OR_EQUAL<=comparison operators
T_LINE__LINE__constants
T_LISTlist()list()
T_LNUMBER123, 012, 0x1ac, etcintegers
T_LOGICAL_ANDandlogical operators
T_LOGICAL_ORorlogical operators
T_LOGICAL_XORxorlogical operators
T_MINUS_EQUAL-=assignment operators
T_ML_COMMENT/* and */comments
T_MOD_EQUAL%=assignment operators
T_MUL_EQUAL*=assignment operators
T_NEWnewclasses and objects
T_NUM_STRING  
T_OBJECT_CAST(object)type-casting
T_OBJECT_OPERATOR->classes and objects
T_OLD_FUNCTIONold_functionold_function
T_OPEN_TAG<?php, <? or <%escaping from HTML
T_OPEN_TAG_WITH_ECHO<?= or <%=escaping from HTML
T_OR_EQUAL|=assignment operators
T_PAAMAYIM_NEKUDOTAYIM::::
T_PLUS_EQUAL+=assignment operators
T_PRINTprint()print()
T_REQUIRErequire()require()
T_REQUIRE_ONCErequire_once()require_once()
T_RETURNreturnreturning values
T_SL<<bitwise operators
T_SL_EQUAL<<=assignment operators
T_SR>>bitwise operators
T_SR_EQUAL>>=assignment operators
T_START_HEREDOC<<<heredoc syntax
T_STATICstaticvariable scope
T_STRING  
T_STRING_CAST(string)type-casting
T_STRING_VARNAME  
T_SWITCHswitchswitch
T_UNSETunset()unset()
T_UNSET_CAST(unset)(not documented; casts to NULL)
T_USEuse(not implemented)
T_VARvarclasses and objects
T_VARIABLE$foovariables
T_WHILEwhilewhile, do..while
T_WHITESPACE  
T_XOR_EQUAL^=assignment operators
T_FUNC_C__FUNCTION__constants, since PHP 4.3.0
T_CLASS_C__CLASS__constants, since PHP 4.3.0