php-src/ext/simplexml/tests/xml_parsing_LIBXML_RECOVER.phpt
Niels Dossche 035a5fdf8c
Add LIBXML_RECOVER (#13504)
Setting the recovery option by using a hardcoded value (1) worked
already for SimpleXML. For DOM, a small change is necessary because
otherwise the recover field overwrites the recovery option.

From a quick search on GitHub [1] it looks like this won't clash with
existing PHP code as no one seems to define (or use) a constant with
such a name.

[1] https://github.com/search?q=LIBXML_RECOVER+language%3APHP&type=code&l=PHP
2024-02-25 21:03:37 +01:00

21 lines
434 B
PHP

--TEST--
XML parsing with LIBXML_RECOVER
--EXTENSIONS--
simplexml
--FILE--
<?php
var_dump(simplexml_load_string('<root><child/>', options: LIBXML_RECOVER));
?>
--EXPECTF--
Warning: simplexml_load_string(): %s
Warning: simplexml_load_string(): <root><child/> in %s on line %d
Warning: simplexml_load_string(): ^ in %s on line %d
object(SimpleXMLElement)#1 (1) {
["child"]=>
object(SimpleXMLElement)#2 (0) {
}
}