在PHP中,urldecode() 函數用于對 URL 編碼后的字符串進行解碼。以下是urldecode() 函數的使用方法:
$url = "https%3A%2F%2Fwww.example.com%2Fpage%3Fid%3D123";
$decoded_url = urldecode($url);
echo $decoded_url;
$url = "https%3A%2F%2Fwww.example.com%2Fpage%3Fid%3D123";
$decoded_url = urldecode($url);
echo $decoded_url;
$str = "Hello%20World%21";
$decoded_str = urldecode($str);
echo $decoded_str;
$str = "%E4%BD%A0%E5%A5%BD";
$decoded_str = urldecode($str);
echo $decoded_str;
注意:在解碼時,需要確保字符串是經過urlencode()函數編碼的,否則可能會出現解碼錯誤。