curl_reset

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

curl_reset重置一个 libcurl 会话句柄的所有的选项

说明

curl_reset(CurlHandle $handle): void

该函数将给定的 cURL 句柄所有选项重新设置为默认值。

参数

handle

curl_init() 返回的 cURL 句柄。

返回值

没有返回值。

更新日志

版本 说明
8.0.0 handle expects a CurlHandle instance now; previously, a resource was expected.

范例

示例 #1 curl_reset() 示例

<?php
// 创建 url 句柄
$ch = curl_init();

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

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

// 发送 HTTP 请求
curl_setopt($ch, CURLOPT_URL, 'http://example.com/');
curl_exec($ch); // 预先设置的 user-agent 不会被发送,它已经被 curl_reset 重置掉了

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

注释

注意:

curl_reset() 还重置作为 curl_init() 参数指定的 URL。

参见

add a note

User Contributed Notes

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