Re: Passing values containing a ? and a &

From: Date: Thu, 22 Feb 2001 19:24:56 +0000
Subject: Re: Passing values containing a ? and a &
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-41199@lists.php.net to get a copy of this message
At 20:11 22.02.2001, Tom Harris said: --------------------[snip]-------------------- >I want to assign a value using the url however the value contains both a ? >and an & so PHP (or the browser) seems to get confused. > >Here's an example: > >http://www.mysite.com/index.php?id=23&url=http://www.anothersite.com/file.ph >p?qid=234&forum=4 > >Everything after url= should be the value of $url but this is not the case. >Is there a way to solve this? --------------------[snip]-------------------- Have a look at the rawurlencode() and rawurldecode() functions. Generally spoken, any variable data passed as GET or POST argument should _always_ be passed in URLEncoded format. MSIE handles this quite nicely by auto-encoding unencoded data, but other browsers miss this. When constructing your GET command line, simply use the rawurlencode() function for any value. Example: <html><body> <?php $time = date ("l dS of F Y h:i:s A"); echo "<a href=\"$PHP_SELF?gettime="; // this line will work everywhere echo rawurlencode($time); // this line will work with MSIE only // echo $time; echo "\">"; echo $time; echo "</a><br>gettime = $gettime"; ?> </body></html> ...ebird >O Ernest E. Vogelsinger (\) http://www.1-at-web.at/ ^ ICQ# 13394035

« previous php.general (#41199) next »