Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
Thread: urlencode() with href
07-19-2012, 11:10 PM #1
- Join Date
- Jul 2012
- Thanked 0 Times in 0 Posts
urlencode() with href
One important point to remember (today it took me 7 hours to find): if you want to pass a link containing blank spaces through urlencode() and then decode it to use in href attribute of an anchor or link, you must not use urldecode(). href does not include blank spaces.
e.g.: header("Location: somepage.php?link=" . urlencode("user/files/some file.pdf"));
and at somepage.php:
DO NOT WRITE: echo "<a href=" . urldecode($_GET["link"]) . " >Click to download</a>";
INSTEAD WRITE: echo "<a href=" . $_GET["link"] . " >Click to download</a>";