<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.domdocument.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'domdocument.prepend.php',
    1 => 'DOMDocument::prepend',
    2 => 'Prepends nodes before the first child node',
  ),
  'up' => 
  array (
    0 => 'class.domdocument.php',
    1 => 'DOMDocument',
  ),
  'prev' => 
  array (
    0 => 'domdocument.normalizedocument.php',
    1 => 'DOMDocument::normalizeDocument',
  ),
  'next' => 
  array (
    0 => 'domdocument.registernodeclass.php',
    1 => 'DOMDocument::registerNodeClass',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/dom/domdocument/prepend.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="domdocument.prepend" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">DOMDocument::prepend</h1>
  <p class="verinfo">(PHP 8)</p><p class="refpurpose"><span class="refname">DOMDocument::prepend</span> &mdash; <span class="dc-title">Prepends nodes before the first child node</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-domdocument.prepend-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>DOMDocument::prepend</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="class.domnode.php" class="type DOMNode">DOMNode</a></span>|<span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">...$nodes</code></span>): <span class="type"><a href="language.types.void.php" class="type void">void</a></span></div>

  <p class="para rdfs-comment">
   Prepends one or many <code class="parameter">nodes</code> to the list of children before the first child node.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-domdocument.prepend-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">nodes</code></dt>
     <dd>
      <p class="para">
       The nodes to prepend.
       Strings are automatically converted to text nodes.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-domdocument.prepend-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   没有返回值。
  </p>
 </div>

 <div class="refsect1 errors" id="refsect1-domdocument.prepend-errors">
  <h3 class="title">错误/异常</h3>
  <dl>
   
 <dt><strong><code><a href="dom.constants.php#constant.dom-hierarchy-request-err">DOM_HIERARCHY_REQUEST_ERR</a></code></strong></dt>
  <dd>
  <p class="para">
    Raised if this node is of a type that does not allow children of the
    type of one of the passed <code class="parameter">nodes</code>, or if the node to
    put in is one of this node&#039;s ancestors or this node itself.
  </p>
 </dd>

   
 <dt><strong><code><a href="dom.constants.php#constant.dom-wrong-document-err">DOM_WRONG_DOCUMENT_ERR</a></code></strong></dt>
  <dd>
  <p class="para">
    Raised if one of the passed <code class="parameter">nodes</code> was created from a different
    document than the one that created this node.
  </p>
 </dd>

  </dl>
 </div>

 <div class="refsect1 changelog" id="refsect1-domdocument.prepend-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.3.0</td>
      <td>
       Calling this method on a node without an owner document now works.
       Previously this threw a
 <span class="classname"><a href="class.domexception.php" class="classname">DOMException</a></span> with code
 <strong><code><a href="dom.constants.php#constant.dom-hierarchy-request-err">DOM_HIERARCHY_REQUEST_ERR</a></code></strong>.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-domdocument.prepend-examples">
  <h3 class="title">示例</h3>
  <div class="example" id="domdocument.prepend.example.basic">
   <p><strong>示例 #1 <span class="methodname"><strong>DOMDocument::prepend()</strong></span> example</strong></p>
   <div class="example-contents"><p>
    Adds nodes before the document root.
   </p></div>
   <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$doc </span><span style="color: #007700">= new </span><span style="color: #0000BB">DOMDocument</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$doc</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">loadXML</span><span style="color: #007700">(</span><span style="color: #DD0000">"&lt;world/&gt;"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$doc</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">prepend</span><span style="color: #007700">(</span><span style="color: #0000BB">$doc</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">createElement</span><span style="color: #007700">(</span><span style="color: #DD0000">"hello"</span><span style="color: #007700">), </span><span style="color: #DD0000">"beautiful"</span><span style="color: #007700">);<br /><br />echo </span><span style="color: #0000BB">$doc</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">saveXML</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

   <div class="example-contents"><p>以上示例会输出:</p></div>
   <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;hello/&gt;
beautiful
&lt;world/&gt;</pre>
</div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-domdocument.prepend-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li><span class="methodname"><a href="domparentnode.prepend.php" class="methodname" rel="rdfs-seeAlso">DOMParentNode::prepend()</a> - Prepends nodes before the first child node</span></li>
   <li><span class="methodname"><a href="domdocument.append.php" class="methodname" rel="rdfs-seeAlso">DOMDocument::append()</a> - Appends nodes after the last child node</span></li>
  </ul>
 </div>


</div><?php manual_footer($setup); ?>