xml_parser_create()

xml_parser_create() — Create an XML parser.

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

xml_parser_create() creates a new XML parser and returns a XMLParser instance to be used by the other XML functions.

Signature

xml_parser_create(?string $encoding = null): XMLParser

Parameters

ParameterTypeWhat it takes
$encoding?stringThe input encoding is automatically detected, so that the encoding parameter specifies only the output encoding. If empty string is passed, the parser attempts to identify which encoding the document is encoded in by looking at the heading 3 or 4 bytes. The default output charset is UTF-8. The supported encodings are ISO-8859-1, UTF-8 and US-ASCII.

Return value

Returns a new XMLParser instance.

Example

The PHP manual ships no example for xml_parser_create(); the signature and the parameter table above are the contract.

Changelog

VersionChange
8.0.0This function returns an XMLParser instance now; previously, a resource was returned, or false on failure.
8.0.0encoding is nullable now.

See also

xml_parser_create_ns()

All PHP 8.5 built-in functions

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