PHPTS:一键免费搭建 Nginx + PHP + MySQL 运行环境

curl_unescape

(PHP 5 >= 5.5.0, PHP 7)

curl_unescape解码给定的 URL 编码的字符串

说明

curl_unescape ( resource $ch , string $str ) : string

该函数解码给定的 URL 编码的字符串。

参数

ch

curl_init() 返回的 cURL 句柄。

str

需要解码的 URL 编码字符串

返回值

返回解码后的字符串 或者在失败时返回 FALSE

范例

Example #1 curl_escape() 示例

<?php
// 创建一个 curl 句柄
$ch curl_init('http://example.com/redirect.php');

// 发送 HTTP 请求并且遵循重定向
curl_setopt($chCURLOPT_FOLLOWLOCATION1);
curl_exec($ch);

// 获取最后的有效 URL
$effective_url curl_getinfo($chCURLINFO_EFFECTIVE_URL);
// 结果: "http://example.com/show_location.php?loc=M%C3%BCnchen"

// 解码这个 URL
$effective_url_decoded curl_unescape($ch$effective_url);
// "http://example.com/show_location.php?loc=München"

// 关闭句柄
curl_close($ch);
?>

注释

Note:

curl_unescape() 不会将加号 (+) 解码成空格。而 urldecode() 会。

参见