|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-07-07 12:12 UTC] saprykin dot dmitry at gmail dot com
Description:
------------
1) Output m headers with the same name using header($header, false)
2) Output n (n > m) headers with the same name using header($header, true)
Result) headers will not be replaced totally.
Script will send to output m last headers sent by header($header, true).
Test script:
---------------
<?php
/**
* PHP VERSION 5.3.0
*/
header('Set-Cookie: name1=; path=/; domain=.simple.ru', false);
header('Set-Cookie: name2=; path=/; domain=.simple.ru', false);
header('Set-Cookie: name3=; path=/; domain=.simple.ru', true);
header('Set-Cookie: name4=; path=/; domain=.simple.ru', true);
header('Set-Cookie: name5=; path=/; domain=.simple.ru', true);
print_r(headers_list());
?>
Expected result:
----------------
Array
(
[0] => Set-Cookie: name5=; path=/; domain=.simple.ru
)
Actual result:
--------------
Array
(
[0] => Set-Cookie: name4=; path=/; domain=.simple.ru
[1] => Set-Cookie: name5=; path=/; domain=.simple.ru
)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 08 08:00:01 2025 UTC |
The second parameter 'replace' for header() function only replaces the first header found in FIFO manner, retaining all the remaining headers. cf. main/SAPI.c calling zend_llist_del_element() in Zend/zend_llist.c (looked 5.3 branch and trunk) Test script: --------------- <?php header('X-Foo: 1', true); header('X-Foo: 2', false); print_r(headers_list()); header('X-Foo: 3', true); print_r(headers_list()); header('X-Foo: 4', false); print_r(headers_list()); header('X-Foo: 5', true); print_r(headers_list()); Expected result: ---------------- Array ( [0] => X-Powered-By: PHP/5.3.6 [1] => X-Foo: 1 [2] => X-Foo: 2 ) Array ( [0] => X-Powered-By: PHP/5.3.6 [1] => X-Foo: 3 ) Array ( [0] => X-Powered-By: PHP/5.3.6 [1] => X-Foo: 3 [2] => X-Foo: 4 ) Array ( [0] => X-Powered-By: PHP/5.3.6 [1] => X-Foo: 5 ) Actual result: -------------- Array ( [0] => X-Powered-By: PHP/5.3.6 [1] => X-Foo: 1 [2] => X-Foo: 2 ) Array ( [0] => X-Powered-By: PHP/5.3.6 [1] => X-Foo: 2 [2] => X-Foo: 3 ) Array ( [0] => X-Powered-By: PHP/5.3.6 [1] => X-Foo: 2 [2] => X-Foo: 3 [3] => X-Foo: 4 ) Array ( [0] => X-Powered-By: PHP/5.3.6 [1] => X-Foo: 3 [2] => X-Foo: 4 [3] => X-Foo: 5 )