|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45350 http_build_query - when 3rd parameter is empty, an empty separator is used
Submitted: 2008-06-24 18:26 UTC Modified: 2008-06-24 18:29 UTC
From: jon at phpsitesolutions dot com Assigned:
Status: Closed Package: *URL Functions
PHP Version: 5.2.6 OS: Linux 2.6.9-67.0.7.ELsmp #1 SMP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: jon at phpsitesolutions dot com
New email:
PHP Version: OS:


 [2008-06-24 18:26 UTC] jon at phpsitesolutions dot com
When using http_build_query, passing an empty 3rd parameter results in no separator being used in the resulting output.

This is incorrect, as the documentation page specifies that 'arg_separator.output' will be used in the event that the 3rd parameter is empty.

To fix this issue in my scripts, I've had to explicitly define the separator to use, using:
$sep = ini_get('arg_separator.output');

Reproduce code:

$query_string = 'mode=order_message&orderids=5048';
parse_str(html_entity_decode($qs), $query_string);

$var = http_build_query($query_string);

echo $var;


Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-06-24 18:29 UTC] jon at phpsitesolutions dot com
Just a note, the sample code I submitted, references "$qs", should be "$query_string".

Additionally, the sample doesn't reproduce the error. This does:


$query_string = 'mode=order_message&orderids=5048';
parse_str(html_entity_decode($query_string), $query_string);

$var = http_build_query($query_string, null, '');

echo $var;


It appears this is probably an expected behavior, so it looks like I'll just have to work around it.

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed May 31 16:03:37 2023 UTC