xml_set_external_entity_ref_handler()
xml_set_external_entity_ref_handler() — Set up external entity reference handler.
Built-in function of PHP 8.5. The manual lists it as available in PHP 4, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
What it does
Sets the external entity reference handler function for the XML parser parser.
Signature
xml_set_external_entity_ref_handler(XMLParser $parser, callable|string|null $handler): true handler(XMLParser $parser, string $open_entity_names, string|false $base, string $system_id, string|false $public_id): bool
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $parser | XMLParser | The XML parser. |
| $handler | callable|string|null | If null is passed, the handler is reset to its default state. Warning An empty string will also reset the handler, however this is deprecated as of PHP 8.4.0. |
Return value
Always returns true.
Example
The PHP manual ships no example for xml_set_external_entity_ref_handler(); the signature and the parameter table above are the contract.
Changelog
| Version | Change |
|---|---|
| 8.4.0 | Passing a non-callable string to handler is now deprecated, use a proper callable for methods, or null to reset the handler. |
| 8.4.0 | The validity of handler as a callable is now checked when setting the handler instead of checking when calling it. |
| 8.0.0 | parser expects an XMLParser instance now; previously, a valid xml resource was expected. |
| 7.3.0 | The return value of the handler is no longer ignored if the extension has been built against libxml. Formerly, the return value has been ignored, and parsing did never stop. |
All PHP 8.5 built-in functions
Reference card built from the PHP manual page xml_set_external_entity_ref_handler() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.