urlencode() and urldecode() Functions?

Q

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

✍: FYIcenter

A

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:

<?php
$r ="100%+";
$url =
"http://fyicenter.com/rate.php?r=".urlencode($r);
echo $url;
?>

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

2007-02-27, 5739👍, 0💬