PHP curl_escape函数

PHP 教程 · 2019-01-23 11:43:12

(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 教程 文章: https://www.codercto.com/courses/l/5.html

查看所有标签

The Little Prover

The Little Prover

Daniel P. Friedman、Carl Eastlund / The MIT Press / 2015-7-10 / USD 38.00

[FROM www.amazon.com]: The Little Prover introduces inductive proofs as a way to determine facts about computer programs. It is written in an approachable, engaging style of question-and-answer, wi......一起来看看 《The Little Prover》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具