English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

Usage and examples of PHP curl_init() function

PHP CURL Reference Manual

(PHP 4 >= 4.0.2, PHP 5)

curl_init — Initialize a CURL session

Syntax

resource curl_init ([ string $url = NULL ] )

Initialize a new session, return a CURL handle for use with curl_setopt(), curl_exec(), and curl_close() functions.

Parameter

url

If this parameter is provided, the CURLOPT_URL option will be set to this value. You can also use the curl_setopt() function to manually set this value.

Return Value

If successful, returns a CURL handle, returns FALSE if an error occurs.

Online Examples

Initialize a new CURL session and fetch a web page

<?php
// Create a new CURL resource
$ch = curl_init();
// Set the URL and corresponding options
curl_setopt($ch, CURLOPT_URL, "http://www.oldtoolbag.com/");
curl_setopt($ch, CURLOPT_HEADER, 0);
// Fetch the URL and pass it to the browser
curl_exec($ch);
// Close the CURL resource and release the system resources
curl_close($ch);
?>

PHP CURL Reference Manual