simplexml_load_string
Function • Params and return types changed in PHP 8.0
Interprets a string of XML into an object.
simplexml_load_string Function synopsis
simplexml_load_string(
string $data,
?string $class_name = SimpleXMLElement::class,
int $options = 0,
string $namespace_or_prefix = "",
bool $is_prefix = false
): SimpleXMLElement|false
Parameters
$data
Typestring
A well-formed XML string
$class_name
OptionalType?stringDefault valueSimpleXMLElement::class
You may use this optional parameter so that
simplexml_load_string will return an object of
the specified class. That class should extend the
SimpleXMLElement class.
$options
OptionalTypeintDefault value0
$namespace_or_prefix
OptionalTypestringDefault value""
Namespace prefix or URI.
$is_prefix
OptionalTypeboolDefault valuefalse
true if $namespace_or_prefix is a prefix, false if it's a URI;
defaults to false.
Return value
TypeSimpleXMLElement|false
Returns an object of class SimpleXMLElement with
properties containing the data held within the xml document, or false on failure.
Changes to the simplexml_load_string Function
PHP 8.0
- Return type added:
SimpleXMLElement|false - Parameter type added for parameter #1 (
$data):string - Parameter type added for parameter #2 (
$class_name):?string - Parameter default value added for position #2 (
$class_name):SimpleXMLElement::class - Parameter type added for parameter #3 (
$options):int - Parameter default value added for position #3 (
$options):0 - Parameter name of parameter #4 changed:
$nsto$namespace_or_prefix - Parameter type added for parameter #4 (
$namespace_or_prefix):string - Parameter default value added for position #4 (
$namespace_or_prefix):"" - Parameter type added for parameter #5 (
$is_prefix):bool - Parameter default value added for position #5 (
$is_prefix):false
simplexml_load_string(
- $data,
+ string $data,
- $class_name,
+ ?string $class_name = SimpleXMLElement::class,
- $options,
+ int $options = 0,
- $ns,
+ string $namespace_or_prefix = "",
- $is_prefix
+ bool $is_prefix = false
- )
+ ): SimpleXMLElement|false simplexml_load_string Function Availability
simplexml_load_string Function Availability| PHP Version | Availability |
|---|---|
| PHP 8.6Upcoming Release | Yes |
| PHP 8.5Supported (Latest) | Yes |
| PHP 8.4Supported | Yes |
| PHP 8.3Security-Fixes Only | Yes |
| PHP 8.2Security-Fixes Only | Yes |
| PHP 8.1Unsupported | Yes |
| PHP 8.0Unsupported | Yes |
| PHP 7.4Unsupported | Yes |
| PHP 7.3Unsupported | Yes |
| PHP 7.2Unsupported | Yes |
| PHP 7.1Unsupported | Yes |
| PHP 7.0Unsupported | Yes |
| PHP 5.6Unsupported | Yes |
| PHP 5.5Unsupported | Yes |
| PHP 5.4Unsupported | Yes |
| PHP 5.3Unsupported | Yes |