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
MichelLSZAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dr_dedoCommented:
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MichelLSZAuthor Commented:
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
0
dr_dedoCommented:
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 !!!
0
MichelLSZAuthor Commented:
Since I have + characters in my GET parameters I need to use urlencode(). Otherwise they are lost.

Thanks a lot for your help.
Michel
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.