xml_set_external_entity_ref_handler
(PHP 4, PHP 5)
xml_set_external_entity_ref_handler — 建立外部实体指向处理器
说明
为 parser 参数指定的 XML 解析器建立外部实体指向处理器函数。参数 start_element_handler 和 end_element_handler 为表示函数名称的字符串,这些函数必须在为 parser 指定的解析器调用 xml_parse() 函数时已存在。
由 handler 参数命名的函数名必须接受五个参数,并应该返回一个整型值。如果处理器的返回值为 FALSE(这也是函数没有确定返回值时的返回值),XML 解析器将停止解析, xml_get_error_code() 函数将返回 XML_ERROR_EXTERNAL_ENTITY_HANDLING。
$parser
, string $open_entity_names
, string $base
, string $system_id
, string $public_id
)-
parser - 第一个参数 parser 为指向要调用处理器的 XML 解析器的指针。
-
open_entity_names -
第二个参数
open_entity_names是为该实体的解析开放的实体名列表(包括被指向的实体名),这些实体名由空格隔开。 -
base -
这个参数是解析外部实体的系统标识符(
system_id)的基础。当前该参数通常都被设置为空字符串。 -
system_id -
第四个参数
system_id是在实体定义声明中指定的系统标识符。 -
public_id -
第五个参数
public_id是在实体定义声明中指定的公共标识符,如果未指定任何标识符,则该字符串为空。公共标识符中的空格将按照 XML 的要求被正常化。
如果处理器函数名被设置为空字符串或者 FALSE,则该有问题的处理器将被屏蔽。
如果处理器被成功的建立,该函数将返回 TRUE;如果 parser 指向的不是合法的解析器,函数该函数将返回 FALSE。
Note: 除了函数名,含有对象引用的数组和方法名也可以作为参数。
参数
-
parser -
A reference to the XML parser to set up external entity reference handler function.
-
handler -
handleris a string containing the name of a function that must exist when xml_parse() is called forparser.The function named by
handlermust accept five parameters, and should return an integer value.If the value returned from the handler isFALSE(which it will be if no value is returned), the XML parser will stop parsing and xml_get_error_code() will returnXML_ERROR_EXTERNAL_ENTITY_HANDLING.handler ( resource$parser, string$open_entity_names, string$base, string$system_id, string$public_id)-
parser - The first parameter, parser, is a reference to the XML parser calling the handler.
-
open_entity_names -
The second parameter,
open_entity_names, is a space-separated list of the names of the entities that are open for the parse of this entity (including the name of the referenced entity). -
base -
This is the base for resolving the system identifier
(
system_id) of the external entity.Currently this parameter will always be set to an empty string. -
system_id -
The fourth parameter,
system_id, is the system identifier as specified in the entity declaration. -
public_id -
The fifth parameter,
public_id, is the public identifier as specified in the entity declaration, or an empty string if none was specified; the whitespace in the public identifier will have been normalized as required by the XML spec.
If a handler function is set to an empty string, or
FALSE, the handler in question is disabled.Note: 除了函数名,含有对象引用的数组和方法名也可以作为参数。
-
返回值
成功时返回 TRUE, 或者在失败时返回 FALSE.
