curl_copy_handle

(PHP 5, PHP 7, PHP 8)

curl_copy_handle復(fù)制一個(gè)cURL句柄和它的所有選項(xiàng)

說明

curl_copy_handle(resource $ch): resource

復(fù)制一個(gè)cURL句柄并保持相同的選項(xiàng)。

參數(shù)

handle

curl_init() 返回的 cURL 句柄。

返回值

返回一個(gè)新的cURL句柄。

范例

示例 #1 復(fù)制一個(gè)cURL句柄

<?php
// 創(chuàng)建一個(gè)新的cURL資源
$ch curl_init();

// 設(shè)置URL和相應(yīng)的選項(xiàng)
curl_setopt($chCURLOPT_URL'http://www.example.com/');
curl_setopt($chCURLOPT_HEADER0);

// 復(fù)制句柄
$ch2 curl_copy_handle($ch);

// 抓取URL (http://www.example.com/) 并把它傳遞給瀏覽器
curl_exec($ch2);

// 關(guān)閉cURL資源,并且釋放系統(tǒng)資源
curl_close($ch2);
curl_close($ch);
?>