我有一個類似于以下的代碼:
$ch = curl_init();
// ...
curl_setopt($ch, CURLOPT_HEADERFUNCTION, function ($ch, $header_line) {
// process $header_line...
return strlen($header_line); // needed by curl
});
// ...
curl_exec($ch);
在該代碼之后,我想繼續使用$ch以重新使用連接,但我不再需要自定義CURLOPT_HEADERFUNCTION回呼。我怎樣才能重置它?我嘗試將其設定為null但沒有用。
uj5u.com熱心網友回復:
設定陣列中的常用選項并在執行之間重置選項:
$common_options = [
CURLOPT_XXX => 'something'
// ...
];
$ch = curl_init();
// First call: common specific options
curl_setopt_array($ch, $common_options);
curl_setopt($ch, CURLOPT_FOO, 'something else');
curl_exec($ch);
// Second call: common options only
curl_reset($ch);
curl_setopt_array($ch, $common_options);
curl_exec($ch);
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/371601.html
上一篇:將標準輸入管道傳輸到cURL標頭
下一篇:在C 中將向量連接到自身時出錯
