array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.xml-set-processing-instruction-handler.php', 1 => 'xml_set_processing_instruction_handler', ), 'up' => array ( 0 => 'ref.xml.php', 1 => 'XML 解析器函数', ), 'prev' => array ( 0 => 'function.xml-set-object.php', 1 => 'xml_set_object', ), 'next' => array ( 0 => 'function.xml-set-start-namespace-decl-handler.php', 1 => 'xml_set_start_namespace_decl_handler', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/xml/functions/xml-set-processing-instruction-handler.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4, PHP 5, PHP 7, PHP 8)
xml_set_processing_instruction_handler — 建立处理指令(PI)处理程序
为 parser
XML 解析器设置处理指令(PI)处理函数。
处理指令有如下格式:
<?target data ?>
PHP 代码通过 <?php
处理指令分隔。因此可以在 XML 文档中使用 PHP
代码。但是 PI 结束标记(?>
)不能是数据的一部分。如果 PI
结束标记存在于嵌入式 PHP 代码的一部分,则 PHP 代码的其余部分以及“真实的”PI 结束标记将会视为字符数据。
parser
XML 解析器。
handler
如果传递 null
或空字符串,处理程序将重置为其默认状态。
如果 handler
是 callable,设置的 callable 将作为处理程序。
如果 handler
是 string,它可以是 xml_set_object()
设置的对象的方法名称。
处理程序的签名必须是:
parser
target
data
总是返回 true
。