|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23152 $http_response_header is empty if server responds with a 4xx/5xx status
Submitted: 2003-04-10 09:35 UTC Modified: 2003-04-14 08:57 UTC
From: maximilian dot errath at uni-graz dot at Assigned: iliaa (profile)
Status: Closed Package: HTTP related
PHP Version: 4.3.1 OS: Solaris 8
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: maximilian dot errath at uni-graz dot at
New email:
PHP Version: OS:


 [2003-04-10 09:35 UTC] maximilian dot errath at uni-graz dot at
When using fopen() to open an URL, $http_response_header
is empty if the server responds with a 4xx or 5xx status.

My script:


  $fp = fopen('http://localhost/no-such-file.txt', 'r');


With PHP 4.2.3 I get

Warning:fopen("http://localhost/no-such-file.txt", "r") - Network is unreachable in /home/errath/packages/php-4.2.3/test.php on line 3
    [0] => HTTP/1.1 404 Not Found
    [1] => Date: Thu, 10 Apr 2003 10:06:38 GMT
    [2] => Server: Apache/1.3.23 (Unix)
    [3] => Connection: close
    [4] => Content-Type: text/html; charset=iso-8859-1

but with PHP 4.3.1 and 4.3.2RC1 I get:

Warning: fopen(http://localhost/no-such-file.txt)
[]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
 in /home/errath/packages/php-4.3.2RC1/test.php on line 3


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-04-14 08:57 UTC]
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at
In case this was a documentation problem, the fix will show up soon at

In case this was a website problem, the change will show
up on the site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 26 12:01:29 2024 UTC