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.
or %>
escaping from HTML T_COALESCE
?? comparison operators T_COALESCE_EQUAL
??= assignment operators [available as of PHP 7.4.0] T_COMMENT
// or #, and /* */ comments T_CONCAT_EQUAL
.= assignment operators T_CONST
const class constants T_CONSTANT_ENCAPSED_STRING
"foo" or 'bar' string syntax T_CONTINUE
continue continue T_CURLY_OPEN
{$ complex variable parsed syntax T_DEC
-- incrementing/decrementing operators T_DECLARE
declare declare T_DEFAULT
default switch T_DIR
__DIR__ magic constants T_DIV_EQUAL
/= assignment operators T_DNUMBER
0.12, etc. floating point numbers T_DO
do do..while T_DOC_COMMENT
/** */ PHPDoc style comments 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
belowT_ECHO
echo echo T_ELLIPSIS
... function arguments T_ELSE
else else T_ELSEIF
elseif elseif T_EMPTY
empty empty[] T_ENCAPSED_AND_WHITESPACE
" $a" constant part of string with variables 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_ENUM
enum Enumerations [available as of PHP 8.1.0] 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__ magic constants T_FINAL
final Final Keyword T_FINALLY
finally Exceptions T_FN
fn arrow functions [available as of PHP 7.4.0] T_FOR
for for T_FOREACH
foreach foreach T_FUNCTION
function functions T_FUNC_C
__FUNCTION__ magic constants T_GLOBAL
global variable scope T_GOTO
goto goto T_HALT_COMPILER
__halt_compiler[] __halt_compiler T_IF
if if T_IMPLEMENTS
implements Object Interfaces T_INC
++ incrementing/decrementing operators T_INCLUDE
include[] include T_INCLUDE_ONCE
include_once[] include_once T_INLINE_HTML
text outside PHP T_INSTANCEOF
instanceof type operators T_INSTEADOF
insteadof Traits T_INTERFACE
interface Object Interfaces T_INT_CAST
[int] or [integer] type-casting 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
classes and objects T_NULLSAFE_OBJECT_OPERATOR
?-> classes and objects T_OPEN_TAG
Chủ Đề