xml_set_default_handler()

xml_set_default_handler() — Set up default 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 default handler function for the XML parser parser.

Signature

xml_set_default_handler(XMLParser $parser, callable|string|null $handler): true handler(XMLParser $parser, string $data): void

Parameters

ParameterTypeWhat it takes
$parserXMLParserThe XML parser.
$handlercallable|string|nullIf 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_default_handler(); the signature and the parameter table above are the contract.

Changelog

VersionChange
8.4.0Passing a non-callable string to handler is now deprecated, use a proper callable for methods, or null to reset the handler.
8.4.0The validity of handler as a callable is now checked when setting the handler instead of checking when calling it.
8.0.0parser expects an XMLParser instance now; previously, a valid xml resource was expected.

All PHP 8.5 built-in functions

Reference card built from the PHP manual page xml_set_default_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.