|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39157 can't catch simplexml error
Submitted: 2006-10-14 05:25 UTC Modified: 2006-10-14 08:50 UTC
From: xing at mac dot com Assigned:
Status: Not a bug Package: SimpleXML related
PHP Version: 5.1.6 OS: linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: xing at mac dot com
New email:
PHP Version: OS:


 [2006-10-14 05:25 UTC] xing at mac dot com
Cannot catch a simple loading error when using simplexml_load_string() loading an invalid xml string.

I understand that that E_WARNING, E_ERROR etc are not exceptions but realisticlly, I expect a loading function to throw an exception when it fails to load a object, not a uncatchable "warning". It also be invalid to say this error class is a "warning" as it is most definitely an error.  

Reproduce code:

try {
        $x = simplexml_load_string("adfasdf");
catch (Exception $e) {
        echo "toast";


Expected result:

Actual result:
Warning: simplexml_load_string(): Entity: line 1: parser error : Start tag expected, '<' not found in...

Warning: simplexml_load_string(): adfasdf in...

Warning: simplexml_load_string(): ^ in...


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-14 08:50 UTC]
Use the
errors.php et al. functions available since 5.1 for catching 
xml errors.

We won't change anything in the way it's done right now.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jul 23 06:01:30 2024 UTC