curl_close

(PHP 4 >= 4.0.2, PHP 5, PHP 7, PHP 8)

curl_closeCierra una sesión CURL

Descripción

curl_close(CurlHandle $handle): void

Nota:

Esta función no tiene efecto. Antes de PHP 8.0.0, esta función se utilizaba para cerrar el recurso.

Cierra una sesión cURL y libera todos los recursos reservados. El identificador cURL handle también es borrado.

Parámetros

ch

El recurso cURL devuelto por curl_init().

Valores devueltos

No devuelve ningún valor.

Historial de cambios

Versión Descripción
8.0.0 handle expects a CurlHandle instance now; previously, a resource was expected.

Ejemplos

Ejemplo #1 Inicializa una sesión cURL y recupera una página web

<?php
// creación de un nuevo recurso cURL
$ch = curl_init();

// configuración de la URL y otras opciones
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/");
curl_setopt($ch, CURLOPT_HEADER, 0);

// recuperación de la URL y visualización en el navegador
curl_exec($ch);

// cierre de la sesión cURL
curl_close($ch);
?>

Ver también

add a note

User Contributed Notes 1 note

up
-3
JS
1 year ago
Although the Note for this call says "Prior to PHP 8.0.0, this function was used to close the resource", I found that PHP 7.4.33 on CentOS is not closing the connection on curl_close.

The workaround if you want to make sure the connection closes immediately after the request is to set the curl option to forbid reuse:

curl_setopt($curl, CURLOPT_FORBID_REUSE, TRUE);
To Top