urlencode() and urldecode() Functions?


What are urlencode() and urldecode() functions in PHP?

✍: FYIcenter


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.

For example, you will get "http://fyicenter.com/rate.php?r=100%25%2B" from this sample code:

$r ="100%+";
$url =
echo $url;

urldecode() returns the URL decoded version of the given string.

2007-02-27, 6535👍, 0💬