DOMProcessingInstruction::__construct
(PHP 5, PHP 7)
DOMProcessingInstruction :: __ construct - 创建一个新的DOMProcessingInstruction对象
描述
public DOMProcessingInstruction::__construct ( string $name [, string $value ] )
创建一个新的DOMProcessingInstruction对象。该对象是只读的。它可以被附加到文档中,但是直到该节点与文档相关联时,附加节点才可以被附加到该节点。要创建可写节点,请使用DOMDocument :: createProcessingInstruction。
参数
name
处理指令的标签名称。
value
处理指令的值。
例子
Example#1创建一个新的 DOMProcessingInstruction 对象
<?php
$dom?=?new?DOMDocument('1.0',?'UTF-8');
$html?=?$dom->appendChild(new?DOMElement('html'));
$body?=?$html->appendChild(new?DOMElement('body'));
$pinode?=?new?DOMProcessingInstruction('php',?'echo?"Hello?World";?');
$body->appendChild($pinode);
echo?$dom->saveXML();?
?>
上面的例子将输出:
<?xml version="1.0" encoding="UTF-8"?>
<html><body><?php echo "Hello World"; ?></body></html>
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com