PHP Velho Oeste 2024

curl_close

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

curl_closecURL 세션을 닫음

설명

void curl_close ( resource $ch )

cURL 세션을 닫고 모든 리소스를 해제합니다. cURL 핸들, ch은 제거됩니다.

인수

ch

curl_init()가 반환한 cURL 핸들입니다.

반환값

값을 반환하지 않습니다.

예제

Example #1 새로운 cURL 세션을 초기화하여 웹 페이지를 가져오는 방법

<?php
// 새로운 cURL 핸들을 생성합니다.
$ch curl_init();

// URL 과 다른 옵션들을 설정합니다.
curl_setopt($chCURLOPT_URL"http://www.example.com/");
curl_setopt($chCURLOPT_HEADER0);

// URL 으로부터 데이터를 가져옵니다.
curl_exec($ch);

// cURL 세션을 닫고 리소스를 제거합니다.
curl_close($ch);
?>

참고

add a note add a note

User Contributed Notes 1 note

up
0
JS
8 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