mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 05:26:57 +08:00
137 lines
5.0 KiB
HTML
137 lines
5.0 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>建立处理指令(PI)处理器</title>
|
||
</head>
|
||
<body class="docs"><div id="layout">
|
||
<div id="layout-content"><div id="function.xml-set-processing-instruction-handler" class="refentry">
|
||
<div class="refnamediv">
|
||
<h1 class="refname">xml_set_processing_instruction_handler</h1>
|
||
<p class="verinfo">(PHP 4, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">xml_set_processing_instruction_handler</span> — <span class="dc-title">
|
||
建立处理指令(PI)处理器
|
||
</span></p>
|
||
|
||
</div>
|
||
|
||
<div class="refsect1 description" id="refsect1-function.xml-set-processing-instruction-handler-description">
|
||
<h3 class="title">说明</h3>
|
||
<div class="methodsynopsis dc-description">
|
||
<span class="methodname"><strong>xml_set_processing_instruction_handler</strong></span>
|
||
( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$parser</code></span>
|
||
, <span class="methodparam"><span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> <code class="parameter">$handler</code></span>
|
||
) : <span class="type">bool</span></div>
|
||
|
||
<p class="para rdfs-comment">
|
||
为 <code class="parameter">parser</code> 参数指定的 XML 解析器建立处理指令(PI)处理器函数。
|
||
</p>
|
||
<p class="para">
|
||
处理指令有如下格式:
|
||
<div class="informalexample">
|
||
<div class="example-contents"><div class="cdata"><pre><?</pre></div><span class="replaceable">target</span>
|
||
<span class="replaceable">data</span><div class="cdata"><pre>?>
|
||
</pre></div></div>
|
||
|
||
</div>
|
||
您可以将 PHP 代码放置在类似的标识符中,但要注意一个限制:在 XML 处理指令(PI)中,PI 的终止符(<em>?></em>)不能被引号引用,因此该字符序列不应该在您用 PI 嵌入到 XML 文档中的 PHP 代码中出现。否则,剩下的 PHP 代码,包括“真正”的 PI 终止符将被当作字符数据处理。
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 parameters" id="refsect1-function.xml-set-processing-instruction-handler-parameters">
|
||
<h3 class="title">参数</h3>
|
||
<p class="para">
|
||
<dl>
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">parser</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
XML 解析器的引用,用于建立处理指令(PI)处理器。
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">handler</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
参数 <code class="parameter">handler</code> 为表示函数名称的字符串,函数必须在为 <code class="parameter">parser</code> 指定的解析器调用 <span class="function"><a href="xml_parse.html" class="function">xml_parse()</a></span> 函数时已存在。
|
||
</p>
|
||
<p class="para">
|
||
由 <code class="parameter">handler</code> 参数命名的函数名必须接受三个参数:
|
||
<div class="methodsynopsis dc-description">
|
||
<span class="methodname"><span class="replaceable">handler</span></span>
|
||
( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$parser</code></span>
|
||
, <span class="methodparam"><span class="type">string</span> <code class="parameter">$target</code></span>
|
||
, <span class="methodparam"><span class="type">string</span> <code class="parameter">$data</code></span>
|
||
)</div>
|
||
|
||
<dl>
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">parser</code></dt>
|
||
|
||
<dd>
|
||
|
||
<span class="simpara">
|
||
第一个参数 <span class="replaceable">parser</span> 为指向要调用处理器的 XML 解析器的指针。
|
||
</span>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">target</code></dt>
|
||
|
||
<dd>
|
||
|
||
<span class="simpara">
|
||
第二个参数 <code class="parameter">target</code> 为 PI 对象(PI target)。
|
||
</span>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">data</code></dt>
|
||
|
||
<dd>
|
||
|
||
<span class="simpara">
|
||
第三个参数 <code class="parameter">data</code> 包含了 PI 数据。
|
||
</span>
|
||
</dd>
|
||
|
||
|
||
</dl>
|
||
|
||
</p>
|
||
<p class="para">
|
||
如果处理器函数名被设置为空字符串或者 <strong><code>FALSE</code></strong>,则该有问题的处理器将被屏蔽。
|
||
</p>
|
||
<blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">除了函数名,含有对象引用的数组和方法名也可以作为参数。</span></p></blockquote>
|
||
</dd>
|
||
|
||
|
||
</dl>
|
||
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 returnvalues" id="refsect1-function.xml-set-processing-instruction-handler-returnvalues">
|
||
<h3 class="title">返回值</h3>
|
||
<p class="para">
|
||
成功时返回 <strong><code>TRUE</code></strong>, 或者在失败时返回 <strong><code>FALSE</code></strong>。
|
||
</p>
|
||
</div>
|
||
|
||
</div></div></div></body></html> |