Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 304
  • Last Modified:

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
0
MichelLSZ
Asked:
MichelLSZ
  • 2
  • 2
1 Solution
 
dr_dedoCommented:
0
 
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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now