This is a list of all PHP 8.0 tokens and their represented values in decimal and hexadecimal. The list exists in the php.net site here https://www.php.net/manual/en/tokens.php but there are no values because these values may change for new releases. When writing token parsing code, we need token names and values, and I don't want to dig into the source code to get the values.
Beware that many, if not all values, may be different along version; PHP 7 may not have the same values with PHP 8. Always use the constants, this is just for reference mainly for debugging.
Blog link https://lytrax.io/blog/dev/php-tokens
Gist link https://gist.github.com/clytras/169931c574c5061bdc1f3458fbffbd53
So here is a list of all PHP 8.0 tokens and with their values.
Token | Value | Hex | Syntax | Reference |
---|---|---|---|---|
T_THROW | 258 | 0x102 | throw |
Exceptions |
T_INCLUDE | 260 | 0x104 | include() |
include |
T_INCLUDE_ONCE | 261 | 0x105 | include_once() |
include_once |
T_REQUIRE | 262 | 0x106 | require() |
require |
T_REQUIRE_ONCE | 263 | 0x107 | require_once() |
require_once |
T_LOGICAL_OR | 264 | 0x108 | or |
logical operators |
T_LOGICAL_XOR | 265 | 0x109 | xor |
logical operators |
T_LOGICAL_AND | 266 | 0x10A | and |
logical operators |
T_PRINT | 267 | 0x10B | print() |
|
T_YIELD | 268 | 0x10C | yield |
generators |
T_DOUBLE_ARROW | 269 | 0x10D | => |
array syntax |
T_YIELD_FROM | 270 | 0x10E | yield from |
generators |
T_PLUS_EQUAL | 271 | 0x10F | += |
assignment operators |
T_MINUS_EQUAL | 272 | 0x110 | -= |
assignment operators |
T_MUL_EQUAL | 273 | 0x111 | *= |
assignment operators |
T_DIV_EQUAL | 274 | 0x112 | /= |
assignment operators |
T_CONCAT_EQUAL | 275 | 0x113 | .= |
assignment operators |
T_MOD_EQUAL | 276 | 0x114 | %= |
assignment operators |
T_AND_EQUAL | 277 | 0x115 | &= |
assignment operators |
T_OR_EQUAL | 278 | 0x116 | |= |
assignment operators |
T_XOR_EQUAL | 279 | 0x117 | ^= |
assignment operators |
T_SL_EQUAL | 280 | 0x118 | <<= |
assignment operators |
T_SR_EQUAL | 281 | 0x119 | >>= |
assignment operators |
T_POW_EQUAL | 282 | 0x11A | **= |
assignment operators |
T_COALESCE_EQUAL | 283 | 0x11B | ??= |
assignment operators |
T_COALESCE | 284 | 0x11C | ?? |
comparison operators |
T_BOOLEAN_OR | 285 | 0x11D | || |
logical operators |
T_BOOLEAN_AND | 286 | 0x11E | && |
logical operators |
T_IS_EQUAL | 287 | 0x11F | == |
comparison operators |
T_IS_NOT_EQUAL | 288 | 0x120 | != or <> |
comparison operators |
T_IS_IDENTICAL | 289 | 0x121 | === |
comparison operators |
T_IS_NOT_IDENTICAL | 290 | 0x122 | !== |
comparison operators |
T_SPACESHIP | 291 | 0x123 | <=> |
comparison operators |
T_IS_SMALLER_OR_EQUAL | 292 | 0x124 | <= |
comparison operators |
T_IS_GREATER_OR_EQUAL | 293 | 0x125 | >= |
comparison operators |
T_SL | 294 | 0x126 | << |
bitwise operators |
T_SR | 295 | 0x127 | >> |
bitwise operators |
T_INSTANCEOF | 296 | 0x128 | instanceof |
type operators |
T_INT_CAST | 297 | 0x129 | (int) or (integer) |
type-casting |
T_DOUBLE_CAST | 298 | 0x12A | (real), (double) or (float) |
type-casting |
T_STRING_CAST | 299 | 0x12B | (string) |
type-casting |
T_ARRAY_CAST | 300 | 0x12C | (array) |
type-casting |
T_OBJECT_CAST | 301 | 0x12D | (object) |
type-casting |
T_BOOL_CAST | 302 | 0x12E | (bool) or (boolean) |
type-casting |
T_UNSET_CAST | 303 | 0x12F | (unset) |
type-casting |
T_POW | 304 | 0x130 | ** |
arithmetic operators |
T_CLONE | 305 | 0x131 | clone |
classes and objects |
T_ELSEIF | 307 | 0x133 | elseif |
elseif |
T_ELSE | 308 | 0x134 | else |
else |
T_LNUMBER | 309 | 0x135 | 123, 012, 0x1ac, etc. |
integers |
T_DNUMBER | 310 | 0x136 | 0.12, etc. |
floating point numbers |
T_STRING | 311 | 0x137 | parent, self, etc. |
parent self T_CONSTANT_ENCAPSED_STRING T_CONSTANT_ENCAPSED_STRING |
T_NAME_FULLY_QUALIFIED | 312 | 0x138 | \App\Namespace |
namespaces |
T_VARIABLE | 315 | 0x13B | $foo |
variables |
T_INLINE_HTML | 316 | 0x13C | text outside PHP | |
T_ENCAPSED_AND_WHITESPACE | 317 | 0x13D | " $a" |
constant part of string with variables |
T_CONSTANT_ENCAPSED_STRING | 318 | 0x13E | "foo" or 'bar' |
string syntax |
T_STRING_VARNAME | 319 | 0x13F | "${a |
complex variable parsed syntax |
T_NUM_STRING | 320 | 0x140 | "$a[0]" |
numeric array index inside string |
T_EVAL | 321 | 0x141 | eval() |
eval() |
T_NEW | 322 | 0x142 | new |
classes and objects |
T_EXIT | 323 | 0x143 | exit or die |
exit() die() |
T_IF | 324 | 0x144 | if |
if |
T_ENDIF | 325 | 0x145 | endif |
if alternative syntax |
T_ECHO | 326 | 0x146 | echo |
echo |
T_DO | 327 | 0x147 | do |
do..while |
T_WHILE | 328 | 0x148 | while |
while do..while |
T_ENDWHILE | 329 | 0x149 | endwhile |
while alternative syntax |
T_FOR | 330 | 0x14A | for |
for |
T_ENDFOR | 331 | 0x14B | endfor |
for alternative syntax |
T_FOREACH | 332 | 0x14C | foreach |
foreach |
T_ENDFOREACH | 333 | 0x14D | endforeach |
foreach alternative syntax |
T_DECLARE | 334 | 0x14E | declare |
declare |
T_ENDDECLARE | 335 | 0x14F | enddeclare |
declare alternative syntax |
T_AS | 336 | 0x150 | as |
foreach |
T_SWITCH | 337 | 0x151 | switch |
switch |
T_ENDSWITCH | 338 | 0x152 | endswitch |
switch alternative syntax |
T_CASE | 339 | 0x153 | case |
switch |
T_DEFAULT | 340 | 0x154 | default |
switch |
T_MATCH | 341 | 0x155 | match |
match |
T_BREAK | 342 | 0x156 | break |
break |
T_CONTINUE | 343 | 0x157 | continue |
continue |
T_GOTO | 344 | 0x158 | goto |
goto |
T_FUNCTION | 345 | 0x159 | function |
functions |
T_FN | 346 | 0x15A | fn |
arrow functions |
T_CONST | 347 | 0x15B | const |
class constants |
T_RETURN | 348 | 0x15C | return |
returning values |
T_TRY | 349 | 0x15D | try |
Exceptions |
T_CATCH | 350 | 0x15E | catch |
Exceptions |
T_FINALLY | 351 | 0x15F | finally |
Exceptions |
T_USE | 352 | 0x160 | use |
namespaces |
T_INSTEADOF | 353 | 0x161 | insteadof |
Traits |
T_GLOBAL | 354 | 0x162 | global |
variable scope |
T_STATIC | 355 | 0x163 | static |
variable scope |
T_ABSTRACT | 356 | 0x164 | abstract |
Class Abstraction |
T_FINAL | 357 | 0x165 | final |
Final Keyword |
T_PRIVATE | 358 | 0x166 | private |
classes and objects |
T_PROTECTED | 359 | 0x167 | protected |
classes and objects |
T_PUBLIC | 360 | 0x168 | public |
classes and objects |
T_VAR | 361 | 0x169 | var |
classes and objects |
T_UNSET | 362 | 0x16A | unset() |
unset() |
T_ISSET | 363 | 0x16B | isset() |
isset() |
T_EMPTY | 364 | 0x16C | empty |
empty() |
T_HALT_COMPILER | 365 | 0x16D | __halt_compiler() |
__halt_compiler |
T_CLASS | 366 | 0x16E | class |
classes and objects |
T_TRAIT | 367 | 0x16F | trait |
Traits |
T_INTERFACE | 368 | 0x170 | interface |
Object Interfaces |
T_EXTENDS | 369 | 0x171 | extends |
extends classes and objects |
T_IMPLEMENTS | 370 | 0x172 | implements |
Object Interfaces |
T_NAMESPACE | 371 | 0x173 | namespace |
namespaces |
T_LIST | 372 | 0x174 | list() |
list() |
T_ARRAY | 373 | 0x175 | array() |
array() array syntax |
T_CALLABLE | 374 | 0x176 | callable |
callable |
T_LINE | 375 | 0x177 | __LINE__ |
magic constants |
T_FILE | 376 | 0x178 | __FILE__ |
magic constants |
T_DIR | 377 | 0x179 | __DIR__ |
magic constants |
T_CLASS_C | 378 | 0x17A | __CLASS__ |
magic constants |
T_TRAIT_C | 379 | 0x17B | __TRAIT__ |
TRAIT |
T_METHOD_C | 380 | 0x17C | __METHOD__ |
magic constants |
T_FUNC_C | 381 | 0x17D | __FUNCTION__ |
magic constants |
T_NS_C | 382 | 0x17E | __NAMESPACE__ |
namespaces |
T_ATTRIBUTE | 383 | 0x17F | #[ |
attributes |
T_INC | 384 | 0x180 | ++ |
incrementing/decrementing operators |
T_DEC | 385 | 0x181 | -- |
incrementing/decrementing operators |
T_OBJECT_OPERATOR | 386 | 0x182 | -> |
classes and objects |
T_NULLSAFE_OBJECT_OPERATOR | 387 | 0x183 | ?-> |
classes and objects |
T_COMMENT | 388 | 0x184 | // or #, and /* */ |
comments |
T_DOC_COMMENT | 389 | 0x185 | /** */ |
PHPDoc style comments |
T_OPEN_TAG | 390 | 0x186 | <?php, <? or <% |
escaping from HTML |
T_OPEN_TAG_WITH_ECHO | 391 | 0x187 | <?= or <%= |
escaping from HTML |
T_CLOSE_TAG | 392 | 0x188 | ?> or %> |
escaping from HTML |
T_WHITESPACE | 393 | 0x189 | \t \r\n |
|
T_START_HEREDOC | 394 | 0x18A | <<< |
heredoc syntax |
T_END_HEREDOC | 395 | 0x18B | heredoc syntax | |
T_DOLLAR_OPEN_CURLY_BRACES | 396 | 0x18C | ${ |
complex variable parsed syntax |
T_CURLY_OPEN | 397 | 0x18D | {$ |
complex variable parsed syntax |
T_DOUBLE_COLON | 398 | 0x18E | :: |
T_PAAMAYIM_NEKUDOTAYIM T_PAAMAYIM_NEKUDOTAYIM |
T_PAAMAYIM_NEKUDOTAYIM | 398 | 0x18E | :: |
:: T_DOUBLE_COLON T_DOUBLE_COLON |
T_NS_SEPARATOR | 399 | 0x18F | \ |
namespaces |
T_ELLIPSIS | 400 | 0x190 | ... |
function arguments |
T_BAD_CHARACTER | 401 | 0x191 |