Bug #53301 [Opn->Bgs]: http_build_query unexpected behavior
| From: | iliaa@php.net | Date: | Sun, 12 Dec 2010 17:45:23 +0000 |
| Subject: | Bug #53301 [Opn->Bgs]: http_build_query unexpected behavior | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-156924@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=53301&edit=1
ID: 53301
Updated by: iliaa@php.net
Reported by: rbysa at yahoo dot com
Summary: http_build_query unexpected behavior
-Status: Open
+Status: Bogus
Type: Bug
Package: *General Issues
Operating System: Ubuntu
PHP Version: 5.3.3
Block user comment: N
Private report: N
New Comment:
Cannot reproduce the issue either.
Previous Comments:
------------------------------------------------------------------------
[2010-11-12 22:41:19] felipe@php.net
I got the expected result...
Array
(
[1234567890123] => foo
)
------------------------------------------------------------------------
[2010-11-12 22:38:08] rbysa at yahoo dot com
Your example does not represent the problem. In my haste I messed up my
own
example code but here it is again.
$var = "1234567890123";
$varArray = array();
$varArray[$var]= "foo";
$build = http_build_query($varArray);
$result = array();
parse_str($build, $result);
print_r($result);
//Expect Array( "1234567890123"=>"foo")
//Actual Array( "123456789012" =>"foo")
------------------------------------------------------------------------
[2010-11-12 22:00:14] felipe@php.net
You need to use:
$var = array('12345678901' => 'foo');
var_dump(http_build_query($var));
As said in the other bug report.
------------------------------------------------------------------------
[2010-11-12 20:34:25] rbysa at yahoo dot com
Also I do want to mention that I saw the previous bug report on this
issue
http://bugs.php.net/bug.php?id=49023
However this bug report has been labeled "bogus" even though the
documentation
does not support the mentioned behavior.
------------------------------------------------------------------------
[2010-11-12 20:26:35] rbysa at yahoo dot com
Description:
------------
http_build_query truncates large integer keys to 12 digits regardless of
them
being passed as a string, integer, or float.
However if the integer value is cast to a string and appended with
non-integer
characters the key is not truncated.
Test script:
---------------
$var = 1234567890123
echo http_build_query($var);
$var = (string)1234567890123
echo http_build_query($var);
$var = (float)1234567890123
echo http_build_query($var);
$var = "1234567890123.asd"
echo http_build_query($var);
Expected result:
----------------
Array([0]=>1234567890123)
Array([0]=>1234567890123)
Array([0]=>1234567890123)
Array([0]=>"1234567890123.asd")
Actual result:
--------------
Array([0]=>123456789012)
Array([0]=>123456789012)
Array([0]=>123456789012)
Array([0]=>"1234567890123.asd")
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=53301&edit=1