PHP Conference Japan 2024

DOMCharacterData 類別

(PHP 5, PHP 7, PHP 8)

簡介

表示具有字元資料的節點。沒有節點直接對應到這個類別,但其他節點會繼承它。

類別概要

class DOMCharacterData extends DOMNode implements DOMChildNode {
/* 繼承的常數 */
/* 屬性 */
公開 字串 $data;
公開 唯讀 整數 $length;
/* 繼承的屬性 */
公開 唯讀 字串 $nodeName;
公開 唯讀 整數 $nodeType;
公開 唯讀 ?DOMNode $parentNode;
公開 唯讀 ?DOMElement $parentElement;
公開 唯讀 DOMNodeList $childNodes;
公開 唯讀 ?DOMNode $firstChild;
公開 唯讀 ?DOMNode $lastChild;
公開唯讀
公開唯讀
公開唯讀
公開唯讀 bool $isConnected;
公開唯讀
公開唯讀
公開 string $prefix;
公開唯讀
公開唯讀
公開 string $textContent;
/* 方法 */
公開 after(DOMNode|string ...$nodes): void
公開 appendData(string $data): true
公開 before(DOMNode|string ...$nodes): void
公開 deleteData(int $offset, int $count): bool
公開 insertData(int $offset, string $data): bool
公開 remove(): void
公開 replaceData(整數 $offset, 整數 $count, 字串 $data): 布林
公開 replaceWith(DOMNode|字串 ...$nodes):
公開 substringData(整數 $offset, 整數 $count): 字串|false
/* 繼承的方法 */
公開 DOMNode::C14N(
    布林 $exclusive = false,
    布林 $withComments = false,
    ?陣列 $xpath = null,
    ?陣列 $nsPrefixes = null
): 字串|false
公開 DOMNode::C14NFile(
    字串 $uri,
    布林 $exclusive = false,
    布林 $withComments = false,
    ?陣列 $xpath = null,
    ?陣列 $nsPrefixes = null
): 整數|false
公開 DOMNode::isSupported(字串 $feature, 字串 $version): 布林值
}

屬性

data

節點的內容。

length

內容的長度。

nextElementSibling

下一個兄弟元素或 null

previousElementSibling

前一個兄弟元素或 null

更新日誌

版本 說明
8.0.0 已新增 nextElementSiblingpreviousElementSibling 屬性。
8.0.0 DOMCharacterData 現在實作了 DOMChildNode

目錄

新增註釋

使用者貢獻筆記 1 則筆記

jesdisciple dot FOO at gmail dot BAR dot com
14 年前
如果您正在尋找節點實際對應的 CDATA 類別,它叫做 DOMCdataSection(根據我的 PHP 安裝版本),而且 php.net 上並沒有相關文件。推測它對這個 API 沒有任何額外功能。

另請參閱:https://php.dev.org.tw/manual/en/domdocument.createcdatasection.php
To Top