php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jon at phpsitesolutions dot com
New email:
PHP Version: OS:

 

 [2008-06-24 18:26 UTC] jon at phpsitesolutions dot com
Description:
------------
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:
---------------
<?php

$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:
----------------
'mode=order_message&orderids=5048'

Actual result:
--------------
'mode=order_messageorderids%3D5048'

Patches

Pull Requests

History

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:

<?php

$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.

Thanks
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri May 09 08:01:35 2025 UTC