We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

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

MichelLSZ
MichelLSZ asked
on
Medium Priority
320 Views
Last Modified: 2006-11-18
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
Comment
Watch Question

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

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

Commented:
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 !!!

Author

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
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.