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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With