略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: PhpToken::getTokenName

2024-05-01

PhpToken::getTokenName

(PHP 8)

PhpToken::getTokenNameReturns the name of the token.

说明

public PhpToken::getTokenName(): ?string

Returns the name of the token.

参数

此函数没有参数。

返回值

An ASCII character for single-char tokens, or one of T_* constant names for known tokens (see 解析器代号列表), or null for unknown tokens.

范例

示例 #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

参见

add a noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/phptoken.gettokenname.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3