Link to home
Start Free TrialLog in
Avatar of MichelLSZ
MichelLSZ

asked on

Special character (+) gets lost when transmitted as GET parameter

Hi!

I have to process URLs having + characters and blanks in their GET parameter. Unfortunately, PHP is replacing the + characters by blanks. By the way, I access the GET parameters using $_GET[parameter].

Is there a way to prevent PHP from converting + characters in a URL to blanks?

Thanks a lot.
Michel
ASKER CERTIFIED SOLUTION
Avatar of dr_dedo
dr_dedo
Flag of Egypt image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MichelLSZ
MichelLSZ

ASKER

Does it mean that there is only the way to use urlencode() and urldecode() for every sent or received GET-Parameter?
At least for preperation of references, like:

<?php
echo "<a href=\"test.php?id=" . urlencode($id) . "\">";
?>

or when using JavaScript:

location.href="test.php?id=" + encodeURIComponent(id);


Michel
urencode as u've seen in php manual, converts special characters by % and two hex digits. If it is vital for you to get all the special characters in your GET, then u got to use URL encode. but if u r planning to use GET with "id" or "pageNum" or numrical stuff like that, your don't have to use it !!!
Since I have + characters in my GET parameters I need to use urlencode(). Otherwise they are lost.

Thanks a lot for your help.
Michel