<?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 => 'de',
  ),
  'this' => 
  array (
    0 => 'domdocument.loadhtml.php',
    1 => 'DOMDocument::loadHTML',
    2 => 'Load HTML from a string',
  ),
  'up' => 
  array (
    0 => 'class.domdocument.php',
    1 => 'DOMDocument',
  ),
  'prev' => 
  array (
    0 => 'domdocument.load.php',
    1 => 'DOMDocument::load',
  ),
  'next' => 
  array (
    0 => 'domdocument.loadhtmlfile.php',
    1 => 'DOMDocument::loadHTMLFile',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/dom/domdocument/loadhtml.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="domdocument.loadhtml" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">DOMDocument::loadHTML</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">DOMDocument::loadHTML</span> &mdash; <span class="dc-title">
   Load HTML from a string
  </span></p>

 </div>
 <div class="refsect1 description" id="refsect1-domdocument.loadhtml-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>DOMDocument::loadHTML</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$source</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$options</code><span class="initializer"> = 0</span></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   The function parses the HTML contained in the string <code class="parameter">source</code>.
   Unlike loading XML, HTML does not have to be well-formed to load.
  </p>
  <div class="warning"><strong class="warning">Warnung</strong>
 <p class="simpara">
  Um modernes HTML zu parsen und zu verarbeiten, sollte
  <span class="classname"><a href="class.dom-htmldocument.php" class="classname">Dom\HTMLDocument</a></span> anstelle von
  <span class="classname"><a href="class.domdocument.php" class="classname">DOMDocument</a></span> verwendet werden.
 </p>
 <p class="simpara">
  Diese Funktion analysiert die Eingabe mit einem HTML 4-Parser. HTML 5, das
  von modernen Webbrowsern verwendet wird, hat andere Parsing-Regeln. Je nach
  Eingabe kann dies zu einer anderen DOM-Struktur führen, weshalb diese
  Funktion nicht bedenkenlos zur Bereinigung von HTML verwendet werden kann.
 </p>
 <p class="simpara">
  Das Verhalten beim Analysieren von HTML kann von der verwendeten Version von
  <code class="literal">libxml</code> abhängen, insbesondere in Bezug auf die
  Randbedingungen und die Fehlerbehandlung.
  Für Analysen, die der HTML5-Spezifikation entsprechen, sollte eine der in
  PHP 8.4 eingeführten Methoden
  <span class="methodname"><a href="dom-htmldocument.createfromstring.php" class="methodname">Dom\HTMLDocument::createFromString()</a></span> oder
  <span class="methodname"><a href="dom-htmldocument.createfromfile.php" class="methodname">Dom\HTMLDocument::createFromFile()</a></span> verwendet werden.
 </p>
 <p class="simpara">
  Beispielsweise schließen einige HTML-Elemente implizit ein übergeordnetes
  Element, wenn sie darauf treffen. Die Regeln für das automatische Schließen
  übergeordneter Elemente unterscheiden sich zwischen HTML 4 und HTML 5, sodass
  die resultierende DOM-Struktur, die <span class="classname"><a href="class.domdocument.php" class="classname">DOMDocument</a></span> sieht,
  sich von der DOM-Struktur unterscheiden kann, die ein Webbrowser sieht.
 </p>
</div>
 </div>

 <div class="refsect1 parameters" id="refsect1-domdocument.loadhtml-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">source</code></dt>
     <dd>
      <p class="para">
       The HTML string.
      </p>
     </dd>
    
    
     <dt><code class="parameter">options</code></dt>
     <dd>
      <p class="para">
  <a href="language.operators.bitwise.php" class="link">Bitweises <code class="literal">OR</code></a>
  von <a href="libxml.constants.php" class="link">libxml-Konstanten</a> für weitere Optionen.
</p>
     </dd>
    
   </dl>
  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-domdocument.loadhtml-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   Gibt bei Erfolg <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> zurück. Bei einem Fehler wird <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> zurückgegeben.
  </p>
 </div>

 <div class="refsect1 errors" id="refsect1-domdocument.loadhtml-errors">
  <h3 class="title">Fehler/Exceptions</h3>
  <p class="para">
   If an empty string is passed as the <code class="parameter">source</code>,
   a warning will be generated. This warning is not generated by libxml
   and cannot be handled using libxml&#039;s error handling functions.
  </p>
  <p class="para">Auch wenn fehlerhaftes HTML erfolgreich laden sollte, kann diese Funktion dennoch Fehler der Stufe <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong> generieren, wenn sie auf falsches Markup stößt. Die <a href="function.libxml-use-internal-errors.php" class="link">Fehlerbehandlungsfunktionen von libxml</a> können genutzt werden, um diese Fehler zu behandeln.</p>
 </div>


 <div class="refsect1 changelog" id="refsect1-domdocument.loadhtml-changelog">
  <h3 class="title">Changelog</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Beschreibung</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.3.0</td>
      <td>
       This function now has a tentative <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> return type.
      </td>
     </tr>

     <tr>
      <td>8.0.0</td>
      <td>
       Calling this function statically will
       now throw an <span class="classname"><a href="class.error.php" class="classname">Error</a></span>.
       Previously, an <strong><code><a href="errorfunc.constants.php#constant.e-deprecated">E_DEPRECATED</a></code></strong> was raised.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-domdocument.loadhtml-examples">
  <h3 class="title">Beispiele</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Beispiel #1 Creating a Document</strong></p>
    <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">loadHTML</span><span style="color: #007700">(</span><span style="color: #DD0000">"&lt;html&gt;&lt;body&gt;Test&lt;br&gt;&lt;/body&gt;&lt;/html&gt;"</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$doc</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">saveHTML</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

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


 <div class="refsect1 seealso" id="refsect1-domdocument.loadhtml-seealso">
  <h3 class="title">Siehe auch</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="methodname"><a href="domdocument.loadhtmlfile.php" class="methodname" rel="rdfs-seeAlso">DOMDocument::loadHTMLFile()</a> - Load HTML from a file</span></li>
    <li><span class="methodname"><a href="domdocument.savehtml.php" class="methodname" rel="rdfs-seeAlso">DOMDocument::saveHTML()</a> - Dumps the internal document into a string using HTML formatting</span></li>
    <li><span class="methodname"><a href="domdocument.savehtmlfile.php" class="methodname" rel="rdfs-seeAlso">DOMDocument::saveHTMLFile()</a> - Dumps the internal document into a file using HTML formatting</span></li>
   </ul>
  </p>
 </div>

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