curl_reset

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

curl_reset重置一個(gè) libcurl 會(huì)話句柄的所有的選項(xiàng)

說(shuō)明

curl_reset(resource $ch): void

該函數(shù)將給定的 cURL 句柄所有選項(xiàng)重新設(shè)置為默認(rèn)值。

參數(shù)

handle

curl_init() 返回的 cURL 句柄。

返回值

沒(méi)有返回值。

范例

示例 #1 curl_reset() 示例

<?php
// 創(chuàng)建一個(gè)url 句柄
$ch curl_init();

// 設(shè)置 CURLOPT_USERAGENT 選項(xiàng)
curl_setopt($chCURLOPT_USERAGENT"My test user-agent");

// 重置所有的預(yù)先設(shè)置的選項(xiàng)
curl_reset($ch);

// 發(fā)送 HTTP 請(qǐng)求
curl_setopt($chCURLOPT_URL'http://example.com/');
curl_exec($ch); // 預(yù)先設(shè)置的 user-agent 不會(huì)被發(fā)送,它已經(jīng)被 curl_reset 重置掉了

// 關(guān)閉句柄
curl_close($ch);
?>

注釋

注意:

curl_reset() also resets the URL given as the curl_init() parameter.

參見(jiàn)