domprocessinginstruction.construct.html

来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 115 行

HTML
115
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>Creates a new DOMProcessingInstruction object</title>  <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="class.domprocessinginstruction.html">DOMProcessingInstruction</a></div> <div class="next" style="text-align: right; float: right;"><a href="class.domtext.html">DOMText</a></div> <div class="up"><a href="class.domprocessinginstruction.html">DOMProcessingInstruction</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="domprocessinginstruction.construct" class="refentry"> <div class="refnamediv">  <h1 class="refname">DOMProcessingInstruction::__construct</h1>  <p class="verinfo">(PHP 5)</p><p class="refpurpose"><span class="refname">DOMProcessingInstruction::__construct</span> &mdash; <span class="dc-title">   Creates a new DOMProcessingInstruction object  </span></p> </div> <div class="refsect1 description">  <h3 class="title">Description</h3>  <div class="classsynopsis">   <div class="ooclass"><a href="class.domprocessinginstruction.html" class="classname">DOMProcessingInstruction</a></div>   <div class="methodsynopsis dc-description">     <span class="methodname"><b><b>__construct</b></b></span>     ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$name</tt></span>    [, <span class="methodparam"><span class="type">string</span> <tt class="parameter">$value</tt></span>   ] )</div>   </div>  <p class="para">   Creates a new <a href="class.domprocessinginstruction.html" class="classname">DOMProcessingInstruction</a> object. This object is read only.    It may be appended to a document, but additional nodes may not be appended to this node until    the node is associated with a document. To create a writeable node, use    <a href="domdocument.createprocessinginstruction.html" class="xref">DOMDocument::createProcessingInstruction</a>.  </p> </div> <div class="refsect1 parameters">  <h3 class="title">Parameters</h3>  <p class="para">   <dl>    <dt>     <span class="term"><i><tt class="parameter">name</tt></i></span>     <dd>      <p class="para">       The tag name of the processing instruction.      </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">value</tt></i></span>     <dd>      <p class="para">       The value of the processing instruction.      </p>     </dd>    </dt>   </dl>  </p> </div> <div class="refsect1 examples">  <h3 class="title">Examples</h3>  <p class="para">   <div class="example">    <p><b>Example #1 Creating a new DOMProcessingInstruction</b></p>    <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br />$dom&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">DOMDocument</span><span style="color: #007700">(</span><span style="color: #DD0000">'1.0'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'UTF-8'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$html&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$dom</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">appendChild</span><span style="color: #007700">(new&nbsp;</span><span style="color: #0000BB">DOMElement</span><span style="color: #007700">(</span><span style="color: #DD0000">'html'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">$body&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$html</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">appendChild</span><span style="color: #007700">(new&nbsp;</span><span style="color: #0000BB">DOMElement</span><span style="color: #007700">(</span><span style="color: #DD0000">'body'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">$pinode&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">DOMProcessingInstruction</span><span style="color: #007700">(</span><span style="color: #DD0000">'php'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'echo&nbsp;"Hello&nbsp;World";&nbsp;'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$body</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">appendChild</span><span style="color: #007700">(</span><span style="color: #0000BB">$pinode</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">$dom</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">saveXML</span><span style="color: #007700">();&nbsp;<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>    </div>    <div class="example-contents"><p>The above example will output:</p></div>    <div class="example-contents"><pre><div class="cdata"><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;html&gt;&lt;body&gt;&lt;?php echo &quot;Hello World&quot;; ?&gt;&lt;/body&gt;&lt;/html&gt;</pre></div>    </pre></div>   </div>  </p> </div> <div class="refsect1 seealso">  <h3 class="title">See Also</h3>  <p class="para">   <ul class="simplelist">    <li class="member"><a href="domdocument.createprocessinginstruction.html" class="xref">DOMDocument::createProcessingInstruction</a></li>   </ul>  </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="class.domprocessinginstruction.html">DOMProcessingInstruction</a></div> <div class="next" style="text-align: right; float: right;"><a href="class.domtext.html">DOMText</a></div> <div class="up"><a href="class.domprocessinginstruction.html">DOMProcessingInstruction</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?