PHP 8.3.4 Released!

curl_close

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

curl_closeBeendet eine cURL-Session

Beschreibung

curl_close(CurlHandle $handle): void

Hinweis:

Diese Funktion hat keine Auswirkung. Vor PHP 8.0.0 wurde sie verwendet, um die Ressource zu schließen.

Diese Funktion beendet eine cURL-Session und gibt alle Ressourcen frei. Das cURL-Handle handle wird ebenfalls gelöscht.

Parameter-Liste

handle

Ein von curl_init() zurückgegebenes cURL-Handle.

Rückgabewerte

Es wird kein Wert zurückgegeben.

Changelog

Version Beschreibung
8.0.0 handle erwartet nun eine CurlHandle-Instanz; vorher wurde eine Ressource erwartet.

Beispiele

Beispiel #1 Initialisierung einer neuen cURL-Session und Abrufen einer Webseite

<?php
// eine neue cURL-Ressource erstellen
$ch = curl_init();

// URL und andere geeignete Optionen setzen
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/");
curl_setopt($ch, CURLOPT_HEADER, 0);

// URL erfassen und an den Browser übergeben
curl_exec($ch);

// cURL-Ressource schließen und Systemressourcen freigeben
curl_close($ch);
?>

Siehe auch

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