rawurldecode
對已編碼的URL 字符串進行解碼
函數:rawurldecode()
適用版本:PHP 4, PHP 5, PHP 7
用法:rawurldecode(string $str): string
函數功能:將經過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() 函數對其進行解碼。解碼後的字符串可以正常顯示,其中的特殊字符(例如冒號、斜杠和空格)被還原為原始字符。