curl_close

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

curl_closeChiude una sessione cURL

Descrizione

curl_close(CurlHandle $handle): void

Nota:

This function has no effect. Prior to PHP 8.0.0, this function was used to close the resource.

Chiude una sessione cURL e libera tutte le risorse. Anche il gestore cURL, handle, viene eliminato.

Elenco dei parametri

ch

Un identificativo cURL restituito da curl_init().

Valori restituiti

Nessun valore viene restituito.

Log delle modifiche

Versione Descrizione
8.0.0 handle expects a CurlHandle instance now; previously, a resource was expected.

Esempi

Example #1 Inizializza una sessione cURL e scarica una pagina

<?php
// crea una nuova risorsa cURL
$ch = curl_init();

// imposta l'URL e altre opzioni appropriate
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/");
curl_setopt($ch, CURLOPT_HEADER, 0);

// prende l'URL e lo passa al browser
curl_exec($ch);

// chiude la risorsa cURL, e libera le risorse di sistema
curl_close($ch);
?>

Vedere anche:

add a note

User Contributed Notes 1 note

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