mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 05:26:57 +08:00
101 lines
7.2 KiB
HTML
101 lines
7.2 KiB
HTML
<!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>Changes the default external entity loader</title>
|
||
</head>
|
||
<body class="docs"><div id="layout">
|
||
<div id="layout-content"><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 >= 5.4.0, PHP 7)</p><p class="refpurpose"><span class="refname">libxml_set_external_entity_loader</span> — <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"><a href="language.types.callable.html" class="type callable">callable</a></span> <code class="parameter">$resolver_function</code></span>
|
||
) : <span class="type">bool</span></div>
|
||
|
||
<p class="para rdfs-comment">
|
||
Changes the default external entity loader.
|
||
</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.html" class="type callable">callable</a></span> that takes three arguments. Two strings, a public id
|
||
and system id, and a context (an array with four keys) as the third argument.
|
||
This callback should return a resource, a string from which a resource can be
|
||
opened, or <strong><code>NULL</code></strong>.
|
||
</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>TRUE</code></strong>, 或者在失败时返回 <strong><code>FALSE</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-6512">
|
||
<p><strong>Example #1 <span class="function"><strong>libxml_set_external_entity_loader()</strong></span> example</strong></p>
|
||
<div class="example-contents">
|
||
<div class="phpcode"><pre><span style="color: #000000">
|
||
<span style="color: #0000BB"><?php<br />$xml </span><span style="color: #007700">= <<<XML<br /></span><span style="color: #DD0000"><!DOCTYPE foo PUBLIC "-//FOO/BAR" "http://example.com/foobar"><br /><foo>bar</foo><br /></span><span style="color: #007700">XML;<br /><br /></span><span style="color: #0000BB">$dtd </span><span style="color: #007700">= <<<DTD<br /></span><span style="color: #DD0000"><!ELEMENT foo (#PCDATA)><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">-></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">-></span><span style="color: #0000BB">validate</span><span style="color: #007700">());<br /></span><span style="color: #0000BB">?></span>
|
||
</span>
|
||
</pre></div>
|
||
</div>
|
||
|
||
<div class="example-contents"><p>以上例程会输出:</p></div>
|
||
<div class="example-contents screen">
|
||
<div class="cdata"><pre>
|
||
string(10) "-//FOO/BAR"
|
||
string(25) "http://example.com/foobar"
|
||
array(4) {
|
||
["directory"] => NULL
|
||
["intSubName"] => NULL
|
||
["extSubURI"] => NULL
|
||
["extSubSystem"] => 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 class="member"><span class="function"><a href="libxml_disable_entity_loader.html" class="function" rel="rdfs-seeAlso">libxml_disable_entity_loader()</a> - Disable the ability to load external entities</span></li>
|
||
</ul>
|
||
</p>
|
||
</div>
|
||
|
||
|
||
</div></div></div></body></html> |