PHP xml_set_external_entity_ref_handler() Function

The xml_set_external_entity_ref_handler() function specifies a function to be called when the parser finds an external entity in the XML document.This function returns TRUE on success, or FALSE on failure.

bool xml_set_external_entity_ref_handler ( resource $parser , callable $handler )

Sets the external entity reference handler function for the XML parser parser.

Example -

ParameterDescription
parserA reference to the XML parser to set up external entity reference handler function.
handlerRequired. Specifies a function to be called when the parser finds an external entity

The Function specified by the "handler" parameter must have five parameters : -

ParameterDescription
parserThe first parameter, parser, is a reference to the XML parser calling the handler.
nameRequired. Specifies a variable containing the name of the external entity
baseRequired. Specifies the base for resolving the system identifier (system_id) of the external entity. Currently, this is always NULL
system_idThe fourth parameter, system_id, is the system identifier as specified in the entity declaration.
public_idThe 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.

Returns TRUE on success or FALSE on failure.