What is the usage of the urldecode function in PHP?
The urldecode function is used to decode a URL string. Special characters in the URL (such as %20 representing a space, %3D representing an equal sign) will be decoded into their corresponding characters. The usage of the urldecode function is as follows:
string urldecode ( string $str )
The parameter $str is the URL string that needs to be decoded. The function returns the decoded string.
Example sentence:
$url = 'http%3A%2F%2Fwww.example.com%2Fpage%3Fid%3D123%26name%3DJohn';
$decodedUrl = urldecode($url);
echo $decodedUrl; // 输出:http://www.example.com/page?id=123&name=John
In the example above, the urldecode function decodes the URL string http%3A%2F%2Fwww.example.com%2Fpage%3Fid%3D123%26name%3DJohn into http://www.example.com/page?id=123&name=John.