← 返回列表

PHP curl_reset函数

PHP curl_reset函数 (PHP 5 >= 5.5.0) curl_reset— 重置libcurl会话句柄的所有选项。 说明 void curl_reset ( resource $ch ) 该函数将重新初始化cURL的所有选项值(默认值)。 注意: curl_reset() 同样会重新设置 curl_init() 的 URL 参数。 参数 ch 由 curl_init() 返回的 cURL 句柄。 返回值 没有返回值。 实例 <?php // 创建一个cURL句柄 $ch = curl_init(); // 设置 CURLOPT_USERAGENT 选项 curl_setopt($ch, CURLOPT_USERAGENT, "My test user-agent"); // 重置所有先前设置的选项 curl_reset($ch); // 发送 HTTP 请求 curl_setopt($ch, CURLOPT_URL, 'http://codingdict.com/'); curl_exec($ch); // the previously set user-agent will be not sent, it has been reset by curl_reset // 关闭句柄 curl_close($ch); ?>

PHP curl_reset函数

(PHP 5 >= 5.5.0)

curl_reset— 重置libcurl会话句柄的所有选项。

说明

void curl_reset ( resource $ch )

该函数将重新初始化cURL的所有选项值(默认值)。

注意: curl_reset() 同样会重新设置 curl_init() 的 URL 参数。

参数

ch

由 curl_init() 返回的 cURL 句柄。

返回值

没有返回值。

实例

<?php
// 创建一个cURL句柄
$ch = curl_init();

// 设置 CURLOPT_USERAGENT 选项
curl_setopt($ch, CURLOPT_USERAGENT, "My test user-agent");

// 重置所有先前设置的选项
curl_reset($ch);

// 发送 HTTP 请求
curl_setopt($ch, CURLOPT_URL, 'http://codingdict.com/');
curl_exec($ch); // the previously set user-agent will be not sent, it has been reset by curl_reset

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

打开资源 ↗

交流与评论