note 95003 rejected from function.http-build-query by thiago
| From: | thiago@php.net | Date: | Tue, 08 Dec 2009 15:24:14 +0000 |
| Subject: | note 95003 rejected from function.http-build-query by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-163716@lists.php.net to get a copy of this message | ||
Note Submitter: php at gimme dot org
----
To: php.net & Marco K. (Germany)
Test the following:
<?php
$param = array(
'_COOKIE' => array(
),
'_HEADER' => array(
'User-Agent' => 'Mozilla...',
),
);
echo http_build_query( $param );
?>
Use your code http_build_query() just return:
&_HEADER[User-Agent]=Mozilla...
And PHP5 http_build_query() just return
_HEADER%5BUser-Agent%5D=Mozilla...
Both http_build_query() function have ignore the
_COOKIE key in this array. I think
http_build_query() Must Return
_COOKIE%5B%5D=&_HEADER%5BUser-Agent%5D=Mozilla...
or
_COOKIE[]=&_HEADER[User-Agent]=Mozilla...
<?php
if( empty( (array)$data ) ){
if( $key === '' )
return '';
else
return sprintf('%s[]=' , $key );
}
foreach ((array)$data as $k => $v) {
....
?>