大网数据广告活动
PHP 语言与运行手册

The Dom\TokenList class

· 52CE 我爱测

Represents a set of tokens in an attribute (e.g. class names).

The Dom\TokenList class

(PHP 8 >= 8.4.0)

简介

Represents a set of tokens in an attribute (e.g. class names).

类摘要

final class Dom\TokenList implements IteratorAggregate, Countable {
/* 属性 */
public readonly int $length;
public string $value;
/* 方法 */
public function add(string ...$tokens): void
public function contains(string $token): bool
public function count(): int
public function getIterator(): Iterator
public function item(int $index): ?string
public function remove(string ...$tokens): void
public function replace(string $token, string $newToken): bool
public function supports(string $token): bool
public function toggle(string $token, ?bool $force = null): bool
}

属性

length

The number of tokens.

value

The value of the attribute linked to this object.

注释

注意:

此 DOM 扩展在处理方法或属性时使用 UTF-8 编码。 解析器方法会自动检测编码,或允许调用者指定编码。

注意:

Tokens in the list can be accessed by array syntax.

目录

来源:PHP Documentation Group · 作者与贡献记录 · CC BY 3.0。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
PHP Documentation Group
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。