php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #34843 headers_list() not functioning as expected
Submitted: 2005-10-12 23:33 UTC Modified: 2005-10-13 11:00 UTC
From: thom at genx dot net Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: Linux 2.6.11
Private report: No CVE-ID: None
 [2005-10-12 23:33 UTC] thom at genx dot net
Description:
------------
The headers_list() function is not functioning as documented.  The documentation example shows the return value of the function to be a numerically indexed array of headers (name and value).  The return value I am seeing excludes the value portion of the reponse headers (values after the ':').

Reproduce code:
---------------
<?php

/* setcookie() will add a response header on its own */
setcookie('foo', 'bar');

/* Define a custom response header
   This will be ignored by most clients */
header("X-Sample-Test: foo");

/* Specify plain text content in our response */
header('Content-type: text/plain');

/* What headers are going to be sent? */
var_dump(headers_list());

?>

Expected result:
----------------
array(4) {
  [0]=>
  string(29) "X-Powered-By: PHP/5.0.0"
  [1]=>
  string(19) "Set-Cookie: foo=bar"
  [2]=>
  string(18) "X-Sample-Test: foo"
  [3]=>
  string(24) "Content-type: text/plain"
}

Actual result:
--------------
array(4) {
  [0]=>
  string(12) "X-Powered-By"
  [1]=>
  string(10) "Set-Cookie"
  [2]=>
  string(13) "X-Sample-Test"
  [3]=>
  string(12) "Content-type"
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-13 11:00 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 09 22:01:33 2025 UTC