Re: Setting variables through an URL
| From: | Kris Dahl | Date: | Thu, 31 Aug 2000 16:55:17 +0000 |
| Subject: | Re: Setting variables through an URL | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-14645@lists.php.net to get a copy of this message | ||
on 8/31/00 9:24 AM, akio at akio584@wanadoo.es wrote:
> Hello everyone!
>
> I have a script, I set two variables through the URL itself, like
>
>
> http://whatever.com/taf.php?ntitle=Any+title&theurl=any+url
>
> I want the $theurl variable to have a plus '+' sign. Instead of the sign I
> get a free space.
>
> Does anyone know how can I fix this thing?
You need to 'urlencode' the plus sign, as it is a special character that is
used to describe a space in a urlencoded string. Essentially it is a way of
escaping characters.
Pretty much is is the percent sign followed by two hexadecimal digits which
form the value of the octet of the character you are trying to display.
+ = %2B
, = %2C
& = %26
so your url should be
http://whatever.com/taf.php?ntitle=Any+title&theurl=any%2Burl
etc.
For additional information, please take a look at RFC1738 which describes
this process. Very simple procedure.
PHP, incidentally will automatically 'unescapes' these characters.
Cheers,
-k