php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #52582 $http_response_header
Submitted: 2010-08-11 16:19 UTC Modified: 2010-08-16 13:31 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: txino at malon dot org Assigned: rquadling (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: txino at malon dot org
New email:
PHP Version: OS:

 

 [2010-08-11 16:19 UTC] txino at malon dot org
Description:
------------
The $http_response_header variable i not global nor superglobal. It seems like a local variable that is created in the same context you call "file_get_contents" or similar.

I don't understand why the documentation does not explain this.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-08-15 09:21 UTC] degeberg@php.net
-Status: Open +Status: Feedback
 [2010-08-15 09:21 UTC] degeberg@php.net
It does explain this:

"When using the HTTP wrapper, $http_response_header will be populated with the HTTP response headers."

It doesn't claim anywhere that $http_response_header is supposed to be a superglobal. What do you suggest the documentation should say?
 [2010-08-15 15:18 UTC] txino at malon dot org
-Status: Feedback +Status: Open
 [2010-08-15 15:18 UTC] txino at malon dot org
It's true. The documentation doesn't say that $http_response_header is
superglobal. It doesn't say anything ;-)
I think it's normal to suposse that it's a superglobal. I thinked so.
A little note saying:

"It's  a local variable that is created in the same context you call
'file_get_contents' ..."

(using a correct english ... please ;-) can help to avoid errors.

Thanks!
 [2010-08-16 13:08 UTC] rquadling@php.net
The variable $http_response_header is an array which is created in the local 
scope.


<?php
function a()
	{
	echo 'In scope : Before : ', (isset($http_response_header) ? 'Exists' : 
'Does not exist'), PHP_EOL;
	file_get_contents('http://www.google.com');
	echo 'In scope : After : ', (isset($http_response_header) ? 'Exists' : 
'Does not exist'), PHP_EOL;
	}

echo 'Out of scope : Before : ', (isset($http_response_header) ? 'Exists' : 
'Does not exist'), PHP_EOL;
a();
echo 'Out of scope : After : ', (isset($http_response_header) ? 'Exists' : 'Does 
not exist'), PHP_EOL;
?>

outputs ...

Out of scope : Before call : Does not exist
In scope : Before call : Does not exist
In scope : After call : Exists
Out of scope : After call : Does not exist
 [2010-08-16 13:16 UTC] rquadling@php.net
-Assigned To: +Assigned To: rquadling
 [2010-08-16 13:20 UTC] rquadling@php.net
Automatic comment from SVN on behalf of rquadling
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=302335
Log: Define the scope of $http_response_header and improved example to reflect the scope. Fix #52582
 [2010-08-16 13:21 UTC] rquadling@php.net
-Status: Assigned +Status: Closed
 [2010-08-16 13:31 UTC] txino at malon dot org
Jejeje! It's too much!!! ;-)
For me, this part is enought:

"The variable $http_response_header is an array which is created in the local 
scope."

But the full version would help somebody ...
 [2020-02-07 06:09 UTC] phpdocbot@php.net
Automatic comment on behalf of rquadling
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=2907db7cac9a253a361e0c873d199f69b06b310e
Log: Define the scope of $http_response_header and improved example to reflect the scope. Fix #52582
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 16 13:01:32 2024 UTC