PHP curl_escape函数
PHP curl_escape函数
(PHP 5 >= 5.5.0)
curl_escape — 对给定的字符串进行URL编码。
说明
string curl_escape ( resource $ch , string $str )
该函数对给定的字符串进行URL编码» RFC 3986。
参数
ch
由 curl_init() 返回的 cURL 句柄。
str
编码字符串
返回值
返回编码字符串,或者在失败时返回 FALSE。
实例
<?php // 创建一个cURL句柄 $ch = curl_init(); // 编码GET参数 $location = curl_escape($ch, 'Hofbräuhaus / München'); // Result: Hofbr%C3%A4uhaus%20%2F%20M%C3%BCnchen // 比较编码后的URL $url = "http://example.com/add_location.php?location={$location}"; // Result: http://example.com/add_location.php?location=Hofbr%C3%A4uhaus%20%2F%20M%C3%BCnchen // 发送HTTP请求并关闭句柄 curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_exec($ch); curl_close($ch); ?>
相关文章
- PHP 安装
- PHP 运算符
- PHP 数组排序
- PHP Cookie
- PHP array_change_key_case() 函数
- PHP array_combine() 函数
- PHP array_flip() 函数
- PHP array_intersect_key() 函数
- PHP array_multisort() 函数
- PHP array_pad() 函数
- PHP array_rand() 函数
- PHP array_replace_recursive() 函数
- PHP array_reverse() 函数
- PHP array_splice() 函数
- PHP array_udiff_uassoc() 函数
- PHP array_uintersect() 函数
- PHP array_uintersect_uassoc() 函数
- PHP array_unique() 函数
- PHP pos() 函数
- PHP 5 Calendar 函数