Forum Moderators: coopster

Message Too Old, No Replies

& and? in GET arguments

         

jamesyap

12:44 pm on Jan 31, 2003 (gmt 0)

10+ Year Member



We like to include arguements in URL such as

file.php?item=apple

what if my 'apple' is something which contains the special character? and sometime & ...

I can't put file.php?item=?apple or file.php?item=&apple

I need the? and & because I am passing in another URL as arguments to the script.

sugarkane

1:05 pm on Jan 31, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Quickest way is to use PHP's urlencode() function before passing any parameters that may contain 'special' characters:

<? $newapple=urlencode($apple);?>

That replaces non-alphanumeric characters with their hex equivalents - eg '?' becomes '%3F'

You can decode it again later using urldecode()

jamesyap

3:55 pm on Jan 31, 2003 (gmt 0)

10+ Year Member



Ok, I get it! Thanks