PHP 8.3.4 Released!

curl_close

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

curl_closeCierra una sesión cURL

Descripción

curl_close(resource $ch): void

Esta función cierra una sesión CURL y libera todos sus recursos. El recurso CURL, ch, también es eliminado.

Parámetros

ch

El recurso cURL devuelto por curl_init().

Valores devueltos

No devuelve ningún valor.

Ejemplos

Ejemplo #1 Inicializar una nueva sesión CURL y capturar una página web

<?php
// Se crea un manejador CURL
$ch = curl_init();

// Se establece la URL y algunas opciones
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/");
curl_setopt($ch, CURLOPT_HEADER, 0);

// Se obtiene la URL indicada y se envía al navegador
curl_exec($ch);

// Se cierra el recurso CURL y se liberan los recursos del sistema
curl_close($ch);
?>

Ver también

add a note

User Contributed Notes 1 note

up
2
JS
6 months 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