Deprecated: Optional parameter $keys declared before required parameter $cms_id is implicitly treated as a required parameter in /home/www/dev/work/class/blog/CmsKey.php on line 75

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$title is deprecated in /home/www/dev/work/website/lvesu/class/controller/blog/php.php on line 28

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$outlink is deprecated in /home/www/dev/work/website/lvesu/template/blog/cms/php.manual.tpl on line 2

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$status is deprecated in /home/www/dev/work/website/lvesu/template/blog/index.head.php on line 2
PHP - Manual: curl_close - 互联网笔记

略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: curl_close

2025-06-02

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);
?>

参见

添加备注

用户贡献的备注 1 note

up
3
JS
1 year 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);

官方地址:https://www.php.net/manual/en/function.curl-close.php

冷却塔厂家 广告
中文GPT4.0无需注册 广告
北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3