Current the following string (inside the quotes) "give me a + plz"
should be encoded correctly to "give%20me%20a%20+%20plz" when passed
as a query string.
Now when the query string is presented with $_GET['x'], the result is
"give me a plz". Clearly wrong.
This leads to people (I'm sure I'm not the only one) using crazy hacks
to get something as simple as a query string var.
rawurlencode('give me a + plz') will produce "give%20me%20a%20%2B%20plz"
which is not "give%20me%20a%20+%20plz", but does not 'drop' the "+" when
someone types in the query string.
The following code can be used to show the error (lines may wrap):
<?php
$str = 'give me a + plz';
echo '
<a href="'.$_SERVER['SCRIPT_NAME'].'?qs='.$str.'">As typed by someone</a><br />
<a href="'.$_SERVER['SCRIPT_NAME'].'?qs='.urlencode($str).'">With
urlencode()
</a><br />
<a href="'.$_SERVER['SCRIPT_NAME'].'?qs='.rawurlencode($str).'">With
rawurlencode()
</a><br />
';
if ($_GET['qs']) {
echo '<p>Results:<br />
'.$_SERVER['QUERY_STRING'].' < $_SERVER[QUERY_STRING]<br />
'.$_GET['qs'].' < $_GET[qs]<br />
'.urldecode($_SERVER['QUERY_STRING']).' <
urldecode($_SERVER[QUERY_STRING])<br />
'.rawurldecode($_SERVER['QUERY_STRING']).' <
rawurldecode($_SERVER[QUERY_STRING])
echo '<p>
What was really passed?? Impossible to tell for sure but less likely to
be what _GET has:<br />'.$real_GET['qs'].'
} // _GET[qs]
?