Delicious Bookmark this on Delicious Share on Facebook SlashdotSlashdot It! Digg! Digg



PHP : Appendices : List of Parser Tokens

Appendix S. List of Parser Tokens

Various parts of the PHP language are represented internally by types like T_SR. PHP outputs identifiers like this one in parse errors, like "Parse error: unexpected T_SR, expecting ',' or ';' in script.php on line 10."

You're supposed to know what T_SR means. For everybody who doesn't know that, here is a table with those identifiers, PHP-syntax and references to the appropriate places in the manual.

Table S.1. Tokens

Token Syntax Reference
T_ABSTRACT abstract the section called “Class Abstraction” (available since PHP 5.0.0)
T_AND_EQUAL &= assignment operators
T_ARRAY array() array(), array syntax
T_ARRAY_CAST (array) type-casting
T_AS as foreach
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_BREAK break break
T_CASE case switch
T_CATCH catch Chapter 11, Exceptions (available since PHP 5.0.0)
T_CHARACTER    
T_CLASS class classes and objects
T_CLONE clone classes and objects (available since PHP 5.0.0)
T_CLOSE_TAG ?> or %>  
T_COMMENT // or #, and /* */ in PHP 5 comments
T_CONCAT_EQUAL .= assignment operators
T_CONST const  
T_CONSTANT_ENCAPSED_STRING "foo" or 'bar' string syntax
T_CONTINUE continue  
T_CURLY_OPEN    
T_DEC -- incrementing/decrementing operators
T_DECLARE declare declare
T_DEFAULT default switch
T_DIV_EQUAL /= assignment operators
T_DNUMBER 0.12, etc floating point numbers
T_DOC_COMMENT /** */ PHPDoc style comments (available since PHP 5.0.0)
T_DO do do..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_DOUBLE_COLON :: see T_PAAMAYIM_NEKUDOTAYIM below
T_ECHO echo echo()
T_ELSE else else
T_ELSEIF elseif elseif
T_EMPTY empty empty()
T_ENCAPSED_AND_WHITESPACE    
T_ENDDECLARE enddeclare declare, alternative syntax
T_ENDFOR endfor for, alternative syntax
T_ENDFOREACH endforeach foreach, alternative syntax
T_ENDIF endif if, alternative syntax
T_ENDSWITCH endswitch switch, alternative syntax
T_ENDWHILE endwhile while, alternative syntax
T_END_HEREDOC   heredoc syntax
T_EVAL eval() eval()
T_EXIT exit or die exit(), die()
T_EXTENDS extends extends, classes and objects
T_FILE __FILE__ constants
T_FINAL final the section called “Final Keyword” (available since PHP 5.0.0)
T_FOR for for
T_FOREACH foreach foreach
T_FUNCTION function or cfunction functions
T_GLOBAL global variable scope
T_HALT_COMPILER __halt_compiler() __halt_compiler (available since PHP 5.1.0)
T_IF if if
T_IMPLEMENTS implements the section called “Object Interfaces” (available since PHP 5.0.0)
T_INC ++ incrementing/decrementing operators
T_INCLUDE include() include()
T_INCLUDE_ONCE include_once() include_once()
T_INLINE_HTML    
T_INSTANCEOF instanceof type operators (available since PHP 5.0.0)
T_INT_CAST (int) or (integer) type-casting
T_INTERFACE interface the section called “Object Interfaces” (available since PHP 5.0.0)
T_ISSET isset() 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_IS_SMALLER_OR_EQUAL <= comparison operators
T_LINE __LINE__ constants
T_LIST list() list()
T_LNUMBER 123, 012, 0x1ac, etc integers
T_LOGICAL_AND and logical operators
T_LOGICAL_OR or logical operators
T_LOGICAL_XOR xor logical operators
T_MINUS_EQUAL -= assignment operators
T_ML_COMMENT /* and */ comments (PHP 4 only)
T_MOD_EQUAL %= assignment operators
T_MUL_EQUAL *= assignment operators
T_NEW new classes and objects
T_NUM_STRING    
T_OBJECT_CAST (object) type-casting
T_OBJECT_OPERATOR -> classes and objects
T_OLD_FUNCTION old_function old_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 :: ::. Also defined as T_DOUBLE_COLON.
T_PLUS_EQUAL += assignment operators
T_PRINT print() print()
T_PRIVATE private classes and objects (available since PHP 5.0.0)
T_PUBLIC public classes and objects (available since PHP 5.0.0)
T_PROTECTED protected classes and objects (available since PHP 5.0.0)
T_REQUIRE require() require()
T_REQUIRE_ONCE require_once() require_once()
T_RETURN return returning 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_STATIC static variable scope
T_STRING    
T_STRING_CAST (string) type-casting
T_STRING_VARNAME    
T_SWITCH switch switch
T_THROW throw Chapter 11, Exceptions (available since PHP 5.0.0)
T_TRY try Chapter 11, Exceptions (available since PHP 5.0.0)
T_UNSET unset() unset()
T_UNSET_CAST (unset) (not documented; casts to NULL)
T_USE use (not implemented)
T_VAR var classes and objects
T_VARIABLE $foo variables
T_WHILE while while, do..while
T_WHITESPACE    
T_XOR_EQUAL ^= assignment operators
T_FUNC_C __FUNCTION__ constants (available since PHP 4.3.0)
T_CLASS_C __CLASS__ constants (available since PHP 4.3.0)


See also token_name().

Related Examples ( Source code ) » tokens



Code Examples / Notes » tokens

ashgenesis

List of Parser Tokens and his numeric value
Array
(
   [T_ML_COMMENT] => T_ML_COMMENT // php4 only
   [T_OLD_FUNCTION] => T_OLD_FUNCTION // show http://fr.php.net/manual/en/migration.old-function.php
   [T_REQUIRE_ONCE] => 258
   [T_REQUIRE] => 259
   [T_EVAL] => 260
   [T_INCLUDE_ONCE] => 261
   [T_INCLUDE] => 262
   [T_LOGICAL_OR] => 263
   [T_LOGICAL_XOR] => 264
   [T_LOGICAL_AND] => 265
   [T_PRINT] => 266
   [T_SR_EQUAL] => 267
   [T_SL_EQUAL] => 268
   [T_XOR_EQUAL] => 269
   [T_OR_EQUAL] => 270
   [T_AND_EQUAL] => 271
   [T_MOD_EQUAL] => 272
   [T_CONCAT_EQUAL] => 273
   [T_DIV_EQUAL] => 274
   [T_MUL_EQUAL] => 275
   [T_MINUS_EQUAL] => 276
   [T_PLUS_EQUAL] => 277
   [T_BOOLEAN_OR] => 278
   [T_BOOLEAN_AND] => 279
   [T_IS_NOT_IDENTICAL] => 280
   [T_IS_IDENTICAL] => 281
   [T_IS_NOT_EQUAL] => 282
   [T_IS_EQUAL] => 283
   [T_IS_GREATER_OR_EQUAL] => 284
   [T_IS_SMALLER_OR_EQUAL] => 285
   [T_SR] => 286
   [T_SL] => 287
   [T_INSTANCEOF] => 288
   [T_UNSET_CAST] => 289
   [T_BOOL_CAST] => 290
   [T_OBJECT_CAST] => 291
   [T_ARRAY_CAST] => 292
   [T_STRING_CAST] => 293
   [T_DOUBLE_CAST] => 294
   [T_INT_CAST] => 295
   [T_DEC] => 296
   [T_INC] => 297
   [T_CLONE] => 298
   [T_NEW] => 299
   [T_EXIT] => 300
   [T_IF] => 301
   [T_ELSEIF] => 302
   [T_ELSE] => 303
   [T_ENDIF] => 304
   [T_LNUMBER] => 305
   [T_DNUMBER] => 306
   [T_STRING] => 307
   [T_STRING_VARNAME] => 308
   [T_VARIABLE] => 309
   [T_NUM_STRING] => 310
   [T_INLINE_HTML] => 311
   [T_CHARACTER] => 312
   [T_BAD_CHARACTER] => 313
   [T_ENCAPSED_AND_WHITESPACE] => 314
   [T_CONSTANT_ENCAPSED_STRING] => 315
   [T_ECHO] => 316
   [T_DO] => 317
   [T_WHILE] => 318
   [T_ENDWHILE] => 319
   [T_FOR] => 320
   [T_ENDFOR] => 321
   [T_FOREACH] => 322
   [T_ENDFOREACH] => 323
   [T_DECLARE] => 324
   [T_ENDDECLARE] => 325
   [T_AS] => 326
   [T_SWITCH] => 327
   [T_ENDSWITCH] => 328
   [T_CASE] => 329
   [T_DEFAULT] => 330
   [T_BREAK] => 331
   [T_CONTINUE] => 332
   [T_FUNCTION] => 333
   [T_CONST] => 334
   [T_RETURN] => 335
   [T_TRY] => 336
   [T_CATCH] => 337
   [T_THROW] => 338
   [T_USE] => 339
   [T_GLOBAL] => 340
   [T_PUBLIC] => 341
   [T_PROTECTED] => 342
   [T_PRIVATE] => 343
   [T_FINAL] => 344
   [T_ABSTRACT] => 345
   [T_STATIC] => 346
   [T_VAR] => 347
   [T_UNSET] => 348
   [T_ISSET] => 349
   [T_EMPTY] => 350
   [T_HALT_COMPILER] => 351
   [T_CLASS] => 352
   [T_INTERFACE] => 353
   [T_EXTENDS] => 354
   [T_IMPLEMENTS] => 355
   [T_OBJECT_OPERATOR] => 356
   [T_DOUBLE_ARROW] => 357
   [T_LIST] => 358
   [T_ARRAY] => 359
   [T_CLASS_C] => 360
   [T_FUNC_C] => 362
   [T_LINE] => 363
   [T_FILE] => 364
   [T_COMMENT] => 365
   [T_DOC_COMMENT] => 366
   [T_OPEN_TAG ] => 367
   [T_OPEN_TAG_WITH_ECHO] => 368
   [T_CLOSE_TAG] => 369
   [T_WHITESPACE] => 370
   [T_START_HEREDOC] => 371
   [T_END_HEREDOC] => 372
   [T_DOLLAR_OPEN_CURLY_BRACES] => 373
   [T_CURLY_OPEN] => 374
   [T_PAAMAYIM_NEKUDOTAYIM] => 375
   [T_DOUBLE_COLON] => 375
)


Change Language


Follow Navioo On Twitter
History of PHP and related projects
Migrating from PHP 5.1.x to PHP 5.2.x
Migrating from PHP 5.0.x to PHP 5.1.x
Migrating from PHP 4 to PHP 5
Migrating from PHP 3 to PHP 4
Migrating from PHP/FI 2 to PHP 3
Debugging PHP
Configure options
php.ini directives
List of Supported Timezones
Extension Categorization
List of Function Aliases
List of Reserved Words
List of Resource Types
List of Supported Protocols/Wrappers
List of Available Filters
List of Supported Socket Transports
PHP type comparison tables
List of Parser Tokens
Userland Naming Guide
eXTReMe Tracker