|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-03-30 01:36 UTC] bjori@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 28 09:00:01 2025 UTC |
Description: ------------ when simplexml_load_file fails (because the target xml file is empty for example) there are multiple, basically useless, errors reported that makes track_errors and $php_errormsg ineffective My workaround has been to load the file using dom and grab it's relevant error message then use interop to switch to simple if everything is ok... definitely sub-optimal. Reproduce code: --------------- <?php //the easiest test is to create an empty file called empty.xml error_reporting(2047); ini_set('display_errors',0); ini_set('track_errors',1); if( ! $x = simplexml_load_file('empty.xml') ){ echo $php_errormsg; } ?> Expected result: ---------------- either: "empty.xml:1: parser error : Document is empty" or: "empty.xml:1: parser error : Start tag expected, '<' not found" Actual result: -------------- "^" If you enable display_errors you'll see that there are 3 warnings for each 'error' ("Document is empty" and "Start tag expected") There's the relevant error, then an empty error message and then the last one where the message is just "^" and because that's the last one, that's the one stored in $php_errormsg.