<?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 => 'uk',
  ),
  '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">Опис</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">Увага</strong>
 <p class="para">
  Ця функція аналізує вхідні дані за допомогою парсера HTML 4. Правила аналізу
  HTML 5, які використовують більш сучасні браузери — інакші. Залежно від
  вхідних даних, DOM-структура може бути зміненою у результаті. Отже, ця функція
  не придатна для безпечного очищення HTML-коду.
 </p>
 <p class="para">
  Повідінка функції під час парсину HTML може залежати від версії
  <code class="literal">libxml</code>, що використовується та частково від граничних
  випадків і обробки помилок. Для парсингу згідно стандарту HTML 5
  використовується метод
  <span class="methodname"><a href="dom-htmldocument.createfromstring.php" class="methodname">Dom\HTMLDocument::createFromString()</a></span> або
  <span class="methodname"><a href="dom-htmldocument.createfromfile.php" class="methodname">Dom\HTMLDocument::createFromFile()</a></span>, починаючи з PHP
  8.4.
 </p>
 <p class="para">
  До прикладу, деякі елементи HTML неявно закривають батьківський елемент одразу
  після себе. Правила автоматичного закривання батьківських елементів в HTML 4
  та HTML 5 відрізняються, і тому клас <span class="classname"><a href="class.domdocument.php" class="classname">DOMDocument</a></span>
  може бачити DOM-структури, що відрізняються від тих, що бачить браузер,
  дозволяючи зловмиснику поламати вихідний HTML-код.
 </p>
</div>
 </div>

 <div class="refsect1 parameters" id="refsect1-domdocument.loadhtml-parameters">
  <h3 class="title">Параметри</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">Побітове
  <code class="literal">АБО</code></a> <a href="libxml.constants.php" class="link">констант опцій
  libxml</a>.
</p>
     </dd>
    
   </dl>
  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-domdocument.loadhtml-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   Повертає <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> у разі успіху або <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> в разі помилки.
  </p>
 </div>

 <div class="refsect1 errors" id="refsect1-domdocument.loadhtml-errors">
  <h3 class="title">Помилки/виключення</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">Хоча неправильний HTML має успішно
завантажитися, ця функція може генерувати <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong>,
виявивши неправильну розмітку. <a href="function.libxml-use-internal-errors.php" class="link">Функції обробки помилок
libxml</a> можна використовувати для обробки цих помилок.</p>
 </div>


 <div class="refsect1 changelog" id="refsect1-domdocument.loadhtml-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>
       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">Приклади</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Приклад #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">Прогляньте також</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); ?>