PHP 8.3.4 Released!

curl_unescape

(PHP 5 >= 5.5.0, PHP 7, PHP 8)

curl_unescapeURL エンコードされた文字列をデコードする

説明

curl_unescape(CurlHandle $handle, string $string): string|false

この関数は、URL エンコードされた文字列をデコードします。

パラメータ

handle

curl_init() が返す cURL ハンドル。

string

デコード対象の文字列。

戻り値

デコードした文字列を返します。失敗した場合に false を返します。

変更履歴

バージョン 説明
8.0.0 handleCurlHandle クラスのインスタンスを期待するようになりました。 これより前のバージョンでは、resource を期待していました。

例1 curl_escape() の例

<?php
// curl ハンドルを作ります
$ch = curl_init('http://example.com/redirect.php');

// HTTP リクエストを送信し、リダイレクトにしたがいます
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_exec($ch);

// 直近の実効 URL を取得します
$effective_url = curl_getinfo($ch, CURLINFO_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);
?>

注意

注意:

curl_unescape() は、プラス記号 (+) をスペースに変換しません。 urldecode() は、この変換をします。

参考

  • curl_escape() - 指定した文字列を URL エンコードする
  • urlencode() - 文字列を URL エンコードする
  • urldecode() - URL エンコードされた文字列をデコードする
  • rawurlencode() - RFC 3986 に基づき URL エンコードを行う
  • rawurldecode() - URL エンコードされた文字列をデコードする

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top