Sophie

Sophie

distrib > Mageia > 7 > x86_64 > by-pkgid > 2b917e0437961edec048f1d15e2d7449 > files > 12529

php-manual-en-7.2.11-1.mga7.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Creates a new SimpleXMLElement object</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="simplexmlelement.children.html">SimpleXMLElement::children</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="simplexmlelement.count.html">SimpleXMLElement::count</a></div>
 <div class="up"><a href="class.simplexmlelement.html">SimpleXMLElement</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="simplexmlelement.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SimpleXMLElement::__construct</h1>
  <p class="verinfo">(PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">SimpleXMLElement::__construct</span> &mdash; <span class="dc-title">
   Creates a new SimpleXMLElement object
  </span></p>

 </div>
 <div class="refsect1 description" id="refsect1-simplexmlelement.construct-description">
  <h3 class="title">Description</h3>
  <div class="constructorsynopsis dc-description">
   <span class="modifier">final</span> <span class="modifier">public</span> <span class="methodname"><strong>SimpleXMLElement::__construct</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$data</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$options</code><span class="initializer"> = 0</span></span>
   [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$data_is_url</code><span class="initializer"> = <strong><code>FALSE</code></strong></span></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$ns</code><span class="initializer"> = &quot;&quot;</span></span>
   [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$is_prefix</code><span class="initializer"> = <strong><code>FALSE</code></strong></span></span>
  ]]]] )</div>

  <p class="para rdfs-comment">
   Creates a new <a href="class.simplexmlelement.html" class="classname">SimpleXMLElement</a> object.
  </p>
 </div>

 
 <div class="refsect1 parameters" id="refsect1-simplexmlelement.construct-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">data</code></dt>

     <dd>

      <p class="para">
       A well-formed XML string or the path or URL to an XML document if 
       <code class="parameter">data_is_url</code> is <strong><code>TRUE</code></strong>.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">options</code></dt>

     <dd>

      <p class="para">
       Optionally used to specify <a href="libxml.constants.html" class="link">additional
       Libxml parameters</a>.
      </p>
      <blockquote class="note"><p><strong class="note">Note</strong>: 
       <p class="para">
        It may be necessary to pass <strong><code><a href="libxml.constants.html#constant.libxml-parsehuge" class="link">LIBXML_PARSEHUGE</a></code></strong>
        to be able to process deeply nested XML or very large text nodes.
       </p>
      </p></blockquote>
     </dd>

    
    
     <dt>
<code class="parameter">data_is_url</code></dt>

     <dd>

      <p class="para">
       By default, <code class="parameter">data_is_url</code> is <strong><code>FALSE</code></strong>. Use <strong><code>TRUE</code></strong> to
       specify that <code class="parameter">data</code> is a path or URL to an XML 
       document instead of <span class="type"><a href="language.types.string.html" class="type string">string</a></span> data.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">ns</code></dt>

     <dd>

      <p class="para">
       Namespace prefix or URI.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">is_prefix</code></dt>

     <dd>

      <p class="para">
       <strong><code>TRUE</code></strong> if <code class="parameter">ns</code> is a prefix, <strong><code>FALSE</code></strong> if it&#039;s a URI;
       defaults to <strong><code>FALSE</code></strong>.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 
 <div class="refsect1 returnvalues" id="refsect1-simplexmlelement.construct-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns a <span class="type"><a href="class.simplexmlelement.html" class="type SimpleXMLElement">SimpleXMLElement</a></span> object representing 
   <code class="parameter">data</code>.
  </p>
 </div>

 
 <div class="refsect1 errors" id="refsect1-simplexmlelement.construct-errors">
  <h3 class="title">Errors/Exceptions</h3>
  <p class="para">
   Produces an <strong><code>E_WARNING</code></strong> error message for each error
   found in the XML data and additionally throws an <a href="class.exception.html" class="classname">Exception</a> if the XML data
   could not be parsed.
  </p>
  <div class="tip"><strong class="tip">Tip</strong>
   <p class="para">
    Use <span class="function"><a href="function.libxml-use-internal-errors.html" class="function">libxml_use_internal_errors()</a></span> to suppress all XML
    errors, and <span class="function"><a href="function.libxml-get-errors.html" class="function">libxml_get_errors()</a></span> to iterate over them
    afterwards.
   </p>
  </div>
 </div>

 
 <div class="refsect1 examples" id="refsect1-simplexmlelement.construct-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <blockquote class="note"><p><strong class="note">Note</strong>: 
    <p class="para">
     Listed examples may include <em>example.php</em>,
     which refers to the XML string found in the first example
     of the <a href="simplexml.examples-basic.html" class="link">basic usage</a> guide.
    </p>
   </p></blockquote>
   <div class="example" id="example-6722">
    <p><strong>Example #1 Create a SimpleXMLElement object</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">include&nbsp;</span><span style="color: #DD0000">'example.php'</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$sxe&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SimpleXMLElement</span><span style="color: #007700">(</span><span style="color: #0000BB">$xmlstr</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">$sxe</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">movie</span><span style="color: #007700">[</span><span style="color: #0000BB">0</span><span style="color: #007700">]-&gt;</span><span style="color: #0000BB">title</span><span style="color: #007700">;<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 screen">
<div class="cdata"><pre>
PHP: Behind the Parser
</pre></div>
    </div>
   </div>
  </p>
  <p class="para">
   <div class="example" id="example-6723">
    <p><strong>Example #2 Create a SimpleXMLElement object from a URL</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$sxe&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SimpleXMLElement</span><span style="color: #007700">(</span><span style="color: #DD0000">'http://example.org/document.xml'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">NULL</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">$sxe</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">asXML</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>

 
 <div class="refsect1 changelog" id="refsect1-simplexmlelement.construct-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>5.2.0</td>
       <td>Added the <code class="parameter">ns</code> and <code class="parameter">is_prefix</code> parameters.</td>
      </tr>

      <tr>
       <td>5.1.2</td>
       <td>Added the <code class="parameter">options</code> and <code class="parameter">data_is_url</code> parameters.</td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>

 
 <div class="refsect1 seealso" id="refsect1-simplexmlelement.construct-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><a href="simplexml.examples-basic.html" class="xref">Basic SimpleXML usage</a></li>
    <li class="member"><span class="function"><a href="function.simplexml-load-string.html" class="function" rel="rdfs-seeAlso">simplexml_load_string()</a> - Interprets a string of XML into an object</span></li>
    <li class="member"><span class="function"><a href="function.simplexml-load-file.html" class="function" rel="rdfs-seeAlso">simplexml_load_file()</a> - Interprets an XML file into an object</span></li>
    <li class="member"><a href="simplexml.examples-errors.html" class="xref">Dealing with XML errors</a></li>
    <li class="member"><span class="function"><a href="function.libxml-use-internal-errors.html" class="function" rel="rdfs-seeAlso">libxml_use_internal_errors()</a> - Disable libxml errors and allow user to fetch error information as needed</span></li>
   </ul>
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="simplexmlelement.children.html">SimpleXMLElement::children</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="simplexmlelement.count.html">SimpleXMLElement::count</a></div>
 <div class="up"><a href="class.simplexmlelement.html">SimpleXMLElement</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>