函数:rawurldecode()
适用版本:PHP 4, PHP 5, PHP 7
用法:rawurldecode(string $str): string
函数功能:将经过 URL 编码的字符串进行解码,将其中的特殊字符还原为原始字符。
参数:
- $str:需要解码的 URL 编码字符串。
返回值:
- 解码后的字符串。
示例:
$url = 'http%3A%2F%2Fwww.example.com%2Fpage%3Fid%3D123%26name%3DJohn%20Doe';
$decodedUrl = rawurldecode($url);
echo $decodedUrl;
输出:
http://www.example.com/page?id=123&name=John Doe
在上面的示例中,我们有一个经过 URL 编码的字符串,使用 rawurldecode() 函数对其进行解码。解码后的字符串可以正常显示,其中的特殊字符(例如冒号、斜杠和空格)被还原为原始字符。