Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

urlencode

Status
Not open for further replies.

Brian56

Programmer
May 29, 2003
66
CA
Hi,

Can someone explain the difference between urlencode and rawurlencode. I am unsure which to use.

Brian
 
urlencode() encodes all non-alphanumeric characters except - (hyphen)_ (underscore) and replaces the spaces with + (plus) signs. This is the way a browser posts form data to the server.

rawurlencode() is basically the same but is RFC1738 compliant. The difference is that spaces are not transformed into + signs.

When passing vars as GET parameters through the URL you want to use urlencode().

When passing e.g. a password to a FTP server in the URL use rawurlencode();
 
To the best of my knowledge:

Both return a string in which all non-alphanumeric characters are replaced with % and a hex value of 2 digits
(with he exception of (-_.) )

urlencode encodes space as + (plus sign)
rawurlencode encodes space as '%20'

t_avatar.jpg

'... and then it wouldn't compile?'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top