[thelist] PHP encoding &s in a URL
Aleem B
aleem.bawany at utoronto.ca
Mon Sep 1 20:54:51 CDT 2003
> On Mon, 1 Sep 2003, fstorr wrote:
>> Okay, 2 replies saying encode, looks like I was nearly there. This
>> is probably obvious, but why doesn't this code work?
>>
>> <a href="encode.php?q=d&t">D&T</a>
>> <? $somevar = urlencode($_GET['q']);
>> echo "somevar equals " .$somevar; ?>
>
> <?php $q = "D&T"; ?>
> <a href="encode.php?q=<?=urlencode($q)?>">D&T</a>
> <a href="encode.php?q=D%26T">D&T</a>
>
> # encode.php:
> echo $_GET['q']; // php automatically urldecodes it...
>
Another alternative is to get the $_SERVER['REQUEST_URI']
to get the entire URL and break it down yourself with a regex
or something
aleem
[ http://aleembawany.com/ ]
More information about the thelist
mailing list