curl_copy_handle

(PHP 5, PHP 7, PHP 8)

curl_copy_handleCopia un recurso cURL con todas sus preferencias

Descripción

curl_copy_handle(CurlHandle $handle): CurlHandle|false

Copia un recurso cURL, devolviendo un nuevo recurso cURL con las mismas preferencias.

Parámetros

ch

El recurso cURL devuelto por curl_init().

Valores devueltos

Devuelve un nuevo recurso cURL, o false en caso de error.

Historial de cambios

Versión Descripción
8.0.0 handle expects a CurlHandle instance now; previously, a resource was expected.
8.0.0 En caso de éxito, esta función devuelve ahora una instancia de CurlHandle; anteriormente se devolvía unresource.

Ejemplos

Ejemplo #1 Copia de un recurso cURL

<?php
// crea un nuevo recurso cURL
$ch = curl_init();

// asigna URL y otras opciones apropiadas
curl_setopt($ch, CURLOPT_URL, 'http://www.example.com/');
curl_setopt($ch, CURLOPT_HEADER, 0);

// copia el recurso
$ch2 = curl_copy_handle($ch);

// captura la URL (http://www.example.com/) y la envía al navegador
curl_exec($ch2);

// cierra los recursos curl y libera los recursos del sistema
curl_close($ch2);
curl_close($ch);
?>

add a note

User Contributed Notes 1 note

up
4
administrator at proxy-list dot org
17 years ago
There is some internal curl error (CURLE_FAILED_INIT) when you are trying to use just copied curl handle in curl_multi_add_handle(). I have checked the same problematic PHP code but with little difference: instead of creating curl’s copy I have used the original one (template). As I expect code works without any error. I think curl_multi_* along with curl_copy_handle() is still raw and needs some improvements.

With best wishes

Vitali Simsive
To Top