CakeFest 2024: The Official CakePHP Conference

DOMCdataSection::__construct

(PHP 5, PHP 7, PHP 8)

DOMCdataSection::__construct新しい DOMCdataSection オブジェクトを作成する

説明

public DOMCdataSection::__construct(string $data)

新しい CDATA ノードを作成します。これは、DOMText クラスと同じように動作します。

パラメータ

data

CDATA ノードの値。省略した場合は、空の CDATA ノードを作成します。

例1 新しい DOMCdataSection オブジェクトの作成

<?php

$dom
= new DOMDocument('1.0', 'utf-8');
$element = $dom->appendChild(new DOMElement('root'));
$text = $element->appendChild(new DOMCdataSection('root value'));
echo
$dom->saveXML();

?>

上の例の出力は以下となります。

<?xml version="1.0" encoding="utf-8"?>
<root><![CDATA[root value]]></root>

参考

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top