xml_set_start_namespace_decl_handler()
xml_set_start_namespace_decl_handler() — Set up start namespace declaration handler.
Built-in function of PHP 8.5. The manual lists it as available in PHP 4 >= 4.0.5, 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
Set a handler to be called when a namespace is declared. Namespace declarations occur inside start tags. But the namespace declaration start handler is called before the start tag handler for each namespace declared in that start tag.
Signature
xml_set_start_namespace_decl_handler(XMLParser $parser, callable|string|null $handler): true handler(XMLParser $parser, string|false $prefix, string $uri): void
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_start_namespace_decl_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. |
See also
xml_set_end_namespace_decl_handler()
All PHP 8.5 built-in functions
Reference card built from the PHP manual page xml_set_start_namespace_decl_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.