curl_close

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

curl_close关闭 cURL 会话

说明

curl_close(CurlHandle $handle): void

注意:

此函数无效。在 PHP 8.0.0 之前,用于关闭资源。

关闭 cURL 会话并且释放所有资源。也会删除 cURL 句柄 handle

参数

handle

curl_init() 返回的 cURL 句柄。

返回值

没有返回值。

更新日志

版本 说明
8.0.0 handle 现在接受 CurlHandle 实例;之前接受 resource

示例

示例 #1 初始化新 cURL 会话并获取网页

<?php
// 创建新 cURL 资源
$ch = curl_init();

// 设置 URL 和相应的选项
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/");
curl_setopt($ch, CURLOPT_HEADER, 0);

// 抓取 URL 并把它传递给浏览器
curl_exec($ch);

// 关闭 cURL 资源,并且释放系统资源
curl_close($ch);
?>

参见

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top