In PHP, xml_parser_get_option() reads the current value of one of the settings of an XML parser.
Each parser has a few options, such as case folding and the target encoding. Use this function to check what a parser is using now, and xml_parser_set_option() to change it.
Syntax
Call xml_parser_get_option() with the values you need. Start with this line.
Returns whether whitespace-only text is skipped (0 or 1).
The available options are XML_OPTION_CASE_FOLDING, XML_OPTION_TARGET_ENCODING, XML_OPTION_SKIP_TAGSTART, and XML_OPTION_SKIP_WHITE. The return type depends on the option.
Library declarations
PHP
xml_parser_get_option(XMLParser $parser, int $option): string|int|bool
Parameters
Parameter
Description
parser
Required. The XMLParser object created by xml_parser_create() or xml_parser_create_ns().
option
Required. One of the XML_OPTION_* constants.
Return Value
Return Value
Description
string
The target encoding name when you ask for XML_OPTION_TARGET_ENCODING.
int
The numeric value for the other options, such as 1 or 0.
PHP Examples
Example 1 — Check the Default Options
Create a parser and read two of its default settings.