php8.5
Home/ Manual/ tokenizer / phptoken/ PhpToken::getTokenName

PhpToken::getTokenName

PHP function Edit on GitHub ✎

(PHP 8)

Returns the name of the token.

Description

PhpToken::getTokenName(): string|null

Returns the name of the token.

Parameters Parameters

Return Values

An ASCII character for single-char tokens, or one of T_* constant names for known tokens (see tokens), or null for unknown tokens.

Examples

PhpToken::getTokenName() example

php
<?php
// known token
$token = new PhpToken(T_ECHO, 'echo');
var_dump($token->getTokenName());   // -> string(6) "T_ECHO"

// single-char token
$token = new PhpToken(ord(';'), ';');
var_dump($token->getTokenName());   // -> string(1) ";"

// unknown token
$token = new PhpToken(10000 , "\0");
var_dump($token->getTokenName());   // -> NULL

See Also

Source: reference/tokenizer/phptoken/getTokenName.xml · from the official PHP manual (php/doc-en)