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

DOMProcessingInstruction::__construct

(PHP 5, PHP 7)

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

描述

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

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

参数

name

处理指令的标签名称。

value

处理指令的值。

例子

Example#1创建一个新的 DOMProcessingInstruction 对象

代码语言:javascript
复制
<?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();?

?>

上面的例子将输出:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<html><body><?php echo "Hello World"; ?></body></html>

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com