Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<PhpToken::__constructPhpToken::is>
^PhpTokenLast updated: Mon, 26 Oct 2026

PhpToken::getTokenName

(PHP 8)

PhpToken::getTokenName — Returns the name of the token.

Description

public function PhpToken::getTokenName(): ?string

Returns the name of the token.

Parameters

This function has no parameters.

Return Values

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

Examples

Example #1 PhpToken::getTokenName() example

<?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


<PhpToken::__constructPhpToken::is>
^PhpTokenLast updated: Mon, 26 Oct 2026