(PHP 5 >= 5.5.0)
curl_escape — 指定された文字列を URL エンコードします。
文字列curl_escape (リソース $ch 、文字列 $str )
この関数は、指定された文字列を URL エンコードします » RFC 3986。
チャンネル
curl_init() によって返される cURL ハンドル。
str
エンコードされた文字列
エンコードされた文字列を返すか、失敗した場合は FALSE を返します。
<?php// cURL ハンドルを作成 $ch =curl_init(); // GET パラメータをエンコード $location =curl_escape($ch, 'Hofbräuhaus / München') // 結果: Hofbr%C3%A4uhaus%20%2F% 20M%C3%BCnchen// エンコードされた URL を比較$url = "http://example.com/add_location.php?location={$location}";// 結果: http://example.com/add_location.php?location=Hofbr%C3%A4uhaus%20%2F%20M %C3%BCnchen// HTTP リクエストを送信し、ハンドルを閉じますcurl_setopt($ch, CURLOPT_URL, $url); CURLOPT_RETURNTRANSFER、true);curl_exec($ch);curl_close($ch);?>