|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-12-07 02:15 UTC] requinix@php.net
-Type: Bug
+Type: Documentation Problem
[2016-12-07 02:15 UTC] requinix@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 02:00:01 2025 UTC |
Description: ------------ `simplexml_load_string()` documentation states > Returns an object of class SimpleXMLElement with properties containing the data held within the xml document, or FALSE on failure. So I expect if `FALSE` is returned - it was failed to parse xml, so the `libxml_get_last_error` returns the actual error. What happens instead - for the empty string the `simplexml_load_string` returns `false` and `libxml_get_last_error` returns previous non actual error. It should be either a documentation additionally clarify the case, or the implementation behave accordingly. Test script: --------------- $previous = libxml_use_internal_errors(true); $doc = simplexml_load_string('foo'); libxml_use_internal_errors($previous); $result = libxml_get_last_error(); $previous = libxml_use_internal_errors(true); $doc = simplexml_load_string(''); libxml_use_internal_errors($previous); $result = libxml_get_last_error(); var_dump($doc, $result); Expected result: ---------------- bool(false) bool(false) Actual result: -------------- bool(false) object(LibXMLError)#2 (6) { ["level"]=> int(3) ["code"]=> int(4) ["column"]=> int(1) ["message"]=> string(34) "Start tag expected, '<' not found " ["file"]=> string(0) "" ["line"]=> int(1) }