Home > Backend Development > PHP Tutorial > php curl_init and curl_setopt functions_PHP tutorial

php curl_init and curl_setopt functions_PHP tutorial

WBOY
Release: 2016-07-20 11:01:09
Original
1215 people have browsed it

php curl_init and curl_setopt functions ​

curl_init
(PHP 4" = 4.0.2, PHP 5)

curl_init - Initialize a curl session

Description
resource curl_init ([string$url=zero])
Initializes a new session and returns a curl handler used by the curl_setopt(), curl_exec(), and curl_close() functions.

Parameters

URL
If provided, the CURLOPT_URL option will be set to its value. You can set it manually using curl_setopt() function.


Return value
Returns a curl handler on success, false error.

Example

Example #1 Initialize a new curl session and get a web page

// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://www.111cn.cn/");
curl_setopt($ch, CURLOPT_HEADER, 0);

// grab URL and pass it to the browser
curl_exec($ch);

// close cURL resource, and free up system resources
curl_close($ch);
?>


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445456.htmlTechArticlephp curl_init with curl_setopt function curl_init (PHP 4 = 4.0.2, PHP 5) curl_init - Initialize a curl MeetingDescriptionResource curl_init ([string $url=zero]) initial...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template