<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.libxml.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'function.libxml-set-external-entity-loader.php',
    1 => 'libxml_set_external_entity_loader',
    2 => 'Changes the default external entity loader',
  ),
  'up' => 
  array (
    0 => 'ref.libxml.php',
    1 => 'Функції libxml',
  ),
  'prev' => 
  array (
    0 => 'function.libxml-get-last-error.php',
    1 => 'libxml_get_last_error',
  ),
  'next' => 
  array (
    0 => 'function.libxml-set-streams-context.php',
    1 => 'libxml_set_streams_context',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/libxml/functions/libxml-set-external-entity-loader.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.libxml-set-external-entity-loader" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">libxml_set_external_entity_loader</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.4.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">libxml_set_external_entity_loader</span> &mdash; <span class="dc-title">Changes the default external entity loader</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.libxml-set-external-entity-loader-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>libxml_set_external_entity_loader</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span></span> <code class="parameter">$resolver_function</code></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   Changes the default external entity loader.
   This can be used to suppress the expansion of arbitrary external entities to avoid XXE attacks,
   even when <strong><code><a href="libxml.constants.php#constant.libxml-noent">LIBXML_NOENT</a></code></strong> has been set for the respective operation,
   and is usually preferable over calling <span class="function"><a href="function.libxml-disable-entity-loader.php" class="function">libxml_disable_entity_loader()</a></span>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.libxml-set-external-entity-loader-parameters">
  <h3 class="title">Параметри</h3>
  <dl>
   
    <dt><code class="parameter">resolver_function</code></dt>
    <dd>
     <p class="para">
      A <span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> with the following signature:
      <div class="methodsynopsis dc-description">
       <span class="methodname"><span class="replaceable">resolver</span></span>(<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$public_id</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$system_id</code></span>, <span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter">$context</code></span>): <span class="type"><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span>|<span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.null.php" class="type null">null</a></span></span></div>

      <dl>
       
        <dt><code class="parameter">public_id</code></dt>
        <dd>
         <span class="simpara">
          The public ID.
         </span>
        </dd>
       
       
        <dt><code class="parameter">system_id</code></dt>
        <dd>
         <span class="simpara">
          The system ID.
         </span>
        </dd>
       
       
        <dt><code class="parameter">context</code></dt>
        <dd>
         <span class="simpara">
          An array with the four elements <code class="literal">&quot;directory&quot;</code>, <code class="literal">&quot;intSubName&quot;</code>,
          <code class="literal">&quot;extSubURI&quot;</code> and <code class="literal">&quot;extSubSystem&quot;</code>.
         </span>
        </dd>
       
      </dl>
      This callable should return a <a href="language.types.resource.php" class="link">resource</a>, a <span class="type"><a href="language.types.string.php" class="type string">string</a></span> from which a resource can be
      opened. If <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> is returned, the entity reference resolution will fail.
     </p>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.libxml-set-external-entity-loader-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 examples" id="refsect1-function.libxml-set-external-entity-loader-examples">
  <h3 class="title">Приклади</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Приклад #1 <span class="function"><strong>libxml_set_external_entity_loader()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$xml </span><span style="color: #007700">= &lt;&lt;&lt;XML<br /></span><span style="color: #DD0000">&lt;!DOCTYPE foo PUBLIC "-//FOO/BAR" "http://example.com/foobar"&gt;<br />&lt;foo&gt;bar&lt;/foo&gt;<br /></span><span style="color: #007700">XML;<br /><br /></span><span style="color: #0000BB">$dtd </span><span style="color: #007700">= &lt;&lt;&lt;DTD<br /></span><span style="color: #DD0000">&lt;!ELEMENT foo (#PCDATA)&gt;<br /></span><span style="color: #007700">DTD;<br /><br /></span><span style="color: #0000BB">libxml_set_external_entity_loader</span><span style="color: #007700">(<br />    function (</span><span style="color: #0000BB">$public</span><span style="color: #007700">, </span><span style="color: #0000BB">$system</span><span style="color: #007700">, </span><span style="color: #0000BB">$context</span><span style="color: #007700">) use(</span><span style="color: #0000BB">$dtd</span><span style="color: #007700">) {<br />        </span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$public</span><span style="color: #007700">);<br />        </span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$system</span><span style="color: #007700">);<br />        </span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$context</span><span style="color: #007700">);<br />        </span><span style="color: #0000BB">$f </span><span style="color: #007700">= </span><span style="color: #0000BB">fopen</span><span style="color: #007700">(</span><span style="color: #DD0000">"php://temp"</span><span style="color: #007700">, </span><span style="color: #DD0000">"r+"</span><span style="color: #007700">);<br />        </span><span style="color: #0000BB">fwrite</span><span style="color: #007700">(</span><span style="color: #0000BB">$f</span><span style="color: #007700">, </span><span style="color: #0000BB">$dtd</span><span style="color: #007700">);<br />        </span><span style="color: #0000BB">rewind</span><span style="color: #007700">(</span><span style="color: #0000BB">$f</span><span style="color: #007700">);<br />        return </span><span style="color: #0000BB">$f</span><span style="color: #007700">;<br />    }<br />);<br /><br /></span><span style="color: #0000BB">$dd </span><span style="color: #007700">= new </span><span style="color: #0000BB">DOMDocument</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$r  </span><span style="color: #007700">= </span><span style="color: #0000BB">$dd</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">loadXML</span><span style="color: #007700">(</span><span style="color: #0000BB">$xml</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$dd</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">validate</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">string(10) &quot;-//FOO/BAR&quot;
string(25) &quot;http://example.com/foobar&quot;
array(4) {
    [&quot;directory&quot;]    =&gt; NULL
    [&quot;intSubName&quot;]   =&gt; NULL
    [&quot;extSubURI&quot;]    =&gt; NULL
    [&quot;extSubSystem&quot;] =&gt; NULL
}
bool(true)</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.libxml-set-external-entity-loader-seealso">
  <h3 class="title">Прогляньте також</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.libxml-disable-entity-loader.php" class="function" rel="rdfs-seeAlso">libxml_disable_entity_loader()</a> - Disable the ability to load external entities</span></li>
    <li><span class="function"><a href="function.libxml-get-external-entity-loader.php" class="function" rel="rdfs-seeAlso">libxml_get_external_entity_loader()</a> - Get the current external entity loader</span></li>
   </ul>
  </p>
 </div>


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