Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

token_name

Description

The token_name of Tokenizer for PHP get the symbolic name of a given PHP token.

Syntax

token_name ( int $id ) : string

Parameters

id

The token value.

Return

The symbolic name of the given id.

Examples

1

<?

$id = 382;

$return = token_name($id);

echo $return;

?>
T_CLASS_C

2

<?

$id = T_OPEN_TAG;

$return = token_name($id);

echo $return;

?>
T_OPEN_TAG

3

<?

$code = "<?
echo 'Hello';
?>";

$array = token_get_all($code);

foreach ($array as $value)
{
    if (is_array($value))
    {
        $id = $value[0];

        $return = token_name($id);

        echo $id . ": " . $return . PHP_EOL;
    }
}

?>
394: T_OPEN_TAG
397: T_WHITESPACE
328: T_ECHO
397: T_WHITESPACE
320: T_CONSTANT_ENCAPSED_STRING
397: T_WHITESPACE
396: T_CLOSE_TAG
HomeMenu