Various parts of the PHP language are represented internally by tokens.
A code snippet that contains an invalid sequence of tokens may lead to errors like
Parse error: syntax error, unexpected token "==", expecting "(" in script.php on line 10."
where token ==
is internally represented by T_IS_EQUAL
.
The following table lists all tokens. They are also available as PHP constants.
Note: Usage of T_* constants
T_* constants values are automatically generated based on PHP's underlying parser infrastructure. This means that the concrete value of a token may change between two PHP versions. This means that your code should never rely directly on the original T_* values taken from PHP version X.Y.Z, to provide some compatibility across multiple PHP versions.
To make use of T_* constants across multiple PHP versions, undefined constants may be defined by the user (using big numbers like
10000
) with an appropriate strategy that will work with both PHP versions and T_* values.<?php
// Prior to PHP 7.4.0, T_FN is not defined.
defined('T_FN') || define('T_FN', 10001);
See also token_name().