Http_build_query turns not_var = yes into ¬_var = yes in some PHP configurations. What for?
This code:
$query = array( "var" => "no", "not_var" => "yes", "var2" => "maybe" ); print http_build_query($query); Outputs:
var=no¬_var=yes&var2=maybe This happens on my machine with PHP 5.3.19. I reproduced this behavior in PHPfiddle . It works as expected on ideone.com running PHP 5.2.11.
Why is this happening?
This is only because your browser encodes the ¬ object, try the following:
print htmlentities(http_build_query($query)); For normal use, this will be absolutely normal.
The reason it is different from ideone vs PHPFiddle is because PHPFiddle just dumps the results in an iframe, and ideone displays its pre-entity encoding so that other displays are not broken.
Have you made a "view source" of the result or are you using it to display?
In fact, it prints the string as expected; it is a browser that interprets it incorrectly.
The string contains ¬ . This is interpreted by the browser as an HTML object, even though there is no end semicolon.
If you look at the source, you will see that the conclusion is really correct.
Decision. If you want this line to be included in the HTML page, you should also use htmlencode.