|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40529 invalid SimpleXMLElement forces HTTP 200 header
Submitted: 2007-02-17 23:17 UTC Modified: 2007-02-18 01:47 UTC
From: PK at eBrain dot nl Assigned:
Status: Not a bug Package: SimpleXML related
PHP Version: 5.2.1 OS: Fedore Core 3
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: PK at eBrain dot nl
New email:
PHP Version: OS:


 [2007-02-17 23:17 UTC] PK at eBrain dot nl
When SimpleXMLElement in run on something invalid or empty, the HTTP status code is forced to 200 and can not be influenced later on. Either this is a bug or expected behavior - in the last case, it should be: documented on + explained how to work around it.

Note: my actual PHP version is: 5.0.4

Reproduce code:
Note: php://input is empty (i.e. a direct request to the page).

$PostXML = new SimpleXMLElement('php://input');
if (empty($PostXML))
	header('HTTP/1.1 400 Bad Request');
	header('HTTP/1.1 202 Accepted');

Expected result:
HTTP Status Code: HTTP/1.1 400

Actual result:
HTTP Status Code: HTTP/1.1 200


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-02-18 01:47 UTC]
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Tue Mar 28 21:03:37 2023 UTC