首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

DOMComment::__construct

(PHP 5, PHP 7)

DOMComment :: __ construct - 创建一个新的DOMComment对象

描述

代码语言:javascript
复制
public DOMComment::__construct ([ string $value ] )

创建一个新的DOMComment对象。该对象是只读的。它可以被附加到文档中,但是直到该节点与文档相关联时,附加节点才可以被附加到该节点。要创建可写节点,请使用DOMDocument :: createComment。

参数

value

评论的价值。

例子

示例#1创建一个新的DOMComment

代码语言:javascript
复制
<?php

$dom?=?new?DOMDocument('1.0',?'iso-8859-1');
$element?=?$dom->appendChild(new?DOMElement('root'));
$comment?=?$element->appendChild(new?DOMComment('root?comment'));
echo?$dom->saveXML();?/*?<?xml?version="1.0"?encoding="iso-8859-1"?><root><!--root?comment--></root>?*/

?>

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com