php8.5
Home/ Manual/ curl / functions/ curl_copy_handle

curl_copy_handle

PHP function Edit on GitHub ✎

(PHP 5, PHP 7, PHP 8)

Copy a cURL handle along with all of its preferences

Description

curl_copy_handle(CurlHandle $handle): CurlHandle|false

Copies a cURL handle keeping the same preferences.

Parameters

Return Values

Returns a new cURL handle, Falseforfailure.

Changelog

VersionDescription
8.0.0On success, this function returns a CurlHandle instance now; previously, a resource was returned.

Examples

Copying a cURL handle

php
<?php
// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, 'http://www.example.com/');
curl_setopt($ch, CURLOPT_HEADER, 0);

// copy the handle
$ch2 = curl_copy_handle($ch);

// grab URL (http://www.example.com/) and pass it to the browser
curl_exec($ch2);
?>

Source: reference/curl/functions/curl-copy-handle.xml · from the official PHP manual (php/doc-en)