|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63106 get_headers( ) loops on localhost
Submitted: 2012-09-18 07:29 UTC Modified: 2012-09-18 14:20 UTC
From: valentiny510 at yahoo dot es Assigned:
Status: Not a bug Package: Streams related
PHP Version: 5.4.7 OS: Windows XP
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: valentiny510 at yahoo dot es
New email:
PHP Version: OS:


 [2012-09-18 07:29 UTC] valentiny510 at yahoo dot es
First I want to say I have an offer of 2x1 bugs. I will start with a bit of history.. (for some reason) I have a test server added to my system32/drivers/etc/hosts. Ex:
and I thought the problem can be the name of something like that, and deletind the line doesn't solve the problem, and then I realized that the problem is the function inself with the localhost.
Is almost understandable becouse it try to get the self headers over and over again. Almost like: function get($headers){return get($headers);}
The subsequent problem is that is bypassing the time limit of the script, 30 seconds (or whatever time limit is) and the script when reach the limit, the limit is restarted and run again for few minutes 'till the browser stop it.
The error.log will have thousands of line with the error limit..
The documentation doesn't say nothing about localhost.

Speaking of error log, here come the second bug. NOTE: only happens with the bug above ! That why I put together. Ok.. lets see..
For production (like almost everybody, i guess) I use:
ini_set('log_errors', false);
ini_set('display_errors', false);
Ok.. When I try to see the error returned by the above bug with "display_error true", nothing is showed, and ONLY when "log_errors are true" it show me the error "Time limit 30 seconds etc...", also it show me the error with "display_errors false" too ! Something strange there..
Maybe is becouse the script running foreaver, when the browser it stop it, the php does have nothing "prepared" to show.. and must get something from the error.log to display something to the browser

To finish, maybe the second is the subsequent of the first bug (almost sure it is), so dont give to mush importance to that, and fix just the first one.

Test script:

Expected result:
The list of all headers..
or some error like "The php can not get the headers from localhohst" :D

Actual result:
The script run forever and ever.. (what a happy ending) ..'till the browser dies.. (what a sad ending)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-09-18 08:28 UTC]
I don't understand what's bug do you mean?

recursive calling getheaders obviously will result a infinite loop.
 [2012-09-18 09:00 UTC] valentiny510 at yahoo dot es
I would espect at least something like var_export( $GLOBALS );
"Nesting level too deep - recursive dependency?"
 [2012-09-18 10:30 UTC]
-Status: Open +Status: Not a bug
 [2012-09-18 10:30 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

no, because the recursive is not predictable for PHP, 

get_headers will send a request to the target url, and get the response,

in your test, the target is the script self, then it call get_headers again and 
 [2012-09-18 12:04 UTC] valentiny510 at yahoo dot es
Is not "predictable" ? What about some static variable or something like this ?
function get_headers( url )
    server_from_where_script_is_called = $_SERVER['host'];
    if ( url == same_server )
        error('Cannot get the headers from the same domain bla bla bla');
        // do normal stuff ...
What about traspassing the script time limit ?
 [2012-09-18 14:20 UTC]
they are even not in the same process..
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Tue Mar 28 21:03:37 2023 UTC