Edit report at https://bugs.php.net/bug.php?id=50407&edit=1
ID: 50407 Comment by: ast dot derek at gmail dot com Reported by: php at gimme dot org Summary: http_build_query() on empty array Status: Not a bug Type: Bug Package: URL related Operating System: Win PHP Version: 5.2.11 Block user comment: N Private report: N New Comment: Not set is not the same as empty: http://example.com/?foo=&bar=2&hash=XXXX $hash = $_GET['hash']; unset($_GET['hash']); if ($hash != hash(http_build_query($_GET))) { echo 'Hash mismatch'; die; } Now we can't check the hash as http_build_query() won't return the "URL-encoded query string from the associative (or indexed) array provided." The original array is not used, a filtered copy was processed instead. Previous Comments: ------------------------------------------------------------------------ [2010-10-06 13:42:29] adam dot zivner at gmail dot com Applications often make distinction between empty and not set. Example: Set filter to '': http://example.com/articles/?filter= Don't change filter, get it from cookies: http://example.com/articles/ But of course, this could be wrong way of using this. Is suggested explanation part of some standard/specification? ------------------------------------------------------------------------ [2009-12-08 10:05:03] j...@php.net Not setting is same as setting it empty. No bug. ------------------------------------------------------------------------ [2009-12-08 08:31:10] php at gimme dot org Description: ------------ http_build_query() ignore the `key` in array( `key` => array() ).. Reproduce code: --------------- <?php $param = array( '_COOKIE' => array(), '_HEADER' => array( 'User-Agent' => 'Mozilla...' , ), ); echo http_build_query( $param ); ?> Expected result: ---------------- _COOKIE%5B0%D=&_HEADER%5BUser-Agent%5D=Mozilla... Actual result: -------------- _HEADER%5BUser-Agent%5D=Mozilla... ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=50407&edit=1