I'm trying to create a form which allows the user to define own custom query key and while I was testing the validation function for the form, I've noticed that %20
in a url query key is converted to a underscore in the $_GET array.
$key = 'a b';
$key = rawurlencode($key);
$value = 'value';
print_r($_GET); // output: Array ( [a_b] => value )
echo '<p>key:' . $key . '</p>';
echo '<p>value:' . $value . '</p>';
echo '<p><a href="' . $_SERVER["REQUEST_URI"] . '?' . $key . '=' . $value . '">test</a></p>';
Are there other characters converted irregularly? I'm not sure "irregular" is the right word here since there might be a rule for this behavior but I didn't expect this would happen.