token_name()

token_name() — Get the symbolic name of a given PHP token.

Built-in function of PHP 8.5. The manual lists it as available in PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

Signature

token_name(int $id): string

Parameters

ParameterTypeWhat it takes
$idintThe token value.

Return value

The symbolic name of the given id.

Example

A runnable snippet:

// 260 is the token value for the T_EVAL token echo token_name(260); // -> "T_EVAL" // a token constant maps to its own name echo token_name(T_FUNCTION); // -> "T_FUNCTION"

All PHP 8.5 built-in functions

Reference card built from the PHP manual page token_name() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.