Home »

What is meant by urlencode and urldecode?

Question ListCategory: PHPWhat is meant by urlencode and urldecode?
milleranthony7 author asked 8 years ago
4 Answers
adamemliy16 author answered 8 years ago

URL coding converts special characters into % signs followed by two hex digits.For example, urlencode(“10.00%”) will return “10%2E00%25?urldecode is just opposite to urlencode

jeanderson295 author answered 8 years ago

urlencode() returns the URL encoded version of the given string. URL coding converts special characters into % signs followed by two hex digits. For example: urlencode(“10.00%”) will return “10%2E00%25″. URL encoded strings are safe to be used as part of URLs.
urldecode() returns the URL decoded version of the given string.String urlencode(str) – Returns the URL encoded version of the input string. String values to be used in URL query string need to be URL encoded. In the URL encoded version:

Alphanumeric characters are maintained as is.
Space characters are converted to “+” characters.
Other non-alphanumeric characters are converted “%” followed by two hex digits representing the converted character.
string urldecode(str) – Returns the original string of the input URL encoded string.

For example:
$discount =”10.00%”;
$url = “http://domain.com/submit.php?disc=”.urlencode($discount);
echo $url;
You will get “http://domain.com/submit.php?disc=10%2E00%25″.

shah_kajal184 author answered 8 years ago

URLencode returns a string in which all non-alphanumeric characters except -_. have been replaced with a percent (%) sign followed by two hex digits and spaces encoded as plus (+) signs.
It is encoded the same way that the posted data from a WWW formis encoded, that is the same way as in application/x-www-form-urlencoded media type. urldecode decodes any %## encoding in the given string.

denielshakespeare5 author answered 8 years ago

URLencode returns a string in which all non-alphanumeric charactersexcept -_. have been replaced with a percent (%)sign followed by two hex digits and spaces encoded as plus (+)
signs.

It is encoded the same way that the posted data from a WWW formis encoded, that is the same way as in
application/x-www-form-urlencoded media type.urldecode decodes any %##
encoding in the given string.

Please login or Register to Submit Answer