Home >Backend Development >PHP Problem >How to close php curl

How to close php curl

藏色散人
藏色散人Original
2021-05-18 09:17:082755browse

In PHP, you can close a cURL session through the "curl_close" method. The syntax is "void curl_close (resource $ch)". This statement can close a cURL session and release all resources, where the cURL handle ch will also be released.

How to close php curl

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

curl_close — Close a cURL session

Description

void curl_close ( resource $ch )

Close a cURL session and release all resources. The cURL handle ch will also be released.

Parameters

ch

The cURL handle returned by curl_init().

Return value

No return value.

Example

Initialize a cURL session to obtain a web page

<?php
// 创建一个新cURL资源
$ch = curl_init();
// 设置URL和相应的选项
curl_setopt($ch, CURLOPT_URL, "http://www.w3cschool.cc/");
curl_setopt($ch, CURLOPT_HEADER, 0);
// 抓取URL并把它传递给浏览器
curl_exec($ch);
// 关闭cURL资源,并且释放系统资源
curl_close($ch);
?>

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to close php curl. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn