1, Curl_init
Role:
Initializes a new session, returning a curl handle for use by the curl_setopt (), curl_exec (), and curl_close () functions.
Format: Curl_init ([string $url = NULL])
If a parameter $url is provided, the CURLOPT_URL option will be set to this value. or use the curl_setopt () function to set this value manually.
function execution returns a curl handle if successful, error returns FALSE.
2, curl_setopt
Function: Set an option for a given Curl session handle
Format: curl_setopt (resource $ch, int $option, mixed $value)
Where parameters: Ch is returned by Curl_init () to the curl handle.
Option needs to set the CURLOPT_XXX options.
Value will be set on the option options.
Returns TRUE when the function executes successfully, FALSE on failure
3, Curl_exec
Function: Executes a given curl session. This function should be called after initializing a curl session and all of the options are set.
Format: curl_exec (Resource $ch)
Where the parameter $ch is the curl handle returned by Curl_init ().
Returns TRUE when the function executes successfully, or FALSE on failure. However, if the Curlopt_returntransfer option is set, the execution result is returned when the function executes successfully, and FALSE on failure.
4, Curl_close
Function: Closes a curl session and frees all resources. The curl handle CH will also be released.
Format: Curl_close (Resource $ch)
Where the parameter $ch is the curl handle returned by Curl_init ().
The function is of type void and has no return value.
Example: Initializing a new curl session and getting a Web page
<?php//Create a new curl resource $ch = Curl_init ();//Set URL and corresponding options curl_setopt ($ch, Curlopt_url, "http://blog.csdn.net/liuruiqun/ curl_setopt ($ch, Curlopt_header, 0);//crawl the URL and pass it to the browser curl_exec ($ch);//Close the Curl resource and release the system Resource Curl_close ($CH); >
Get a Web page with a Curl session