Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between urlencode and rawurlencode? [closed]

Tags:

security

php

I read the reference question urlencode vs rawurlencode? in the way, that I should use rawurlencode

e.g.

If interoperability with other systems is important then it seems rawurlencode is the way to go.

But why was urlencode invented then? Does it mean this function is useless?

like image 563
Ryan Avatar asked Sep 23 '12 18:09

Ryan


1 Answers

It depends on what you are after. A main difference between them is the standard that they encode to of course, but also spaces.

urlencode encodes the same way that form data is encoded

urlencode encodes spaces as + symbols while rawurlencode encodes them as %20.

Therefore when dealing with form data, urlencode would be preferable (as forms encode spaces as + signs too). Otherwise rawurlencode is a wiser choice in my opinion.

For example, you may want to mimic form data being submitted via a URL, you would use urlencode.

like image 106
David Avatar answered Oct 05 '22 15:10

David