Php curl packet capture can be implemented in PHP by using the file_get_contents () function to collect page content, and curl
CURL request process
The curl request is completed in the following four steps:
1. initialize and create a new curl resource (namely: curl_init ())
2. set the URL and corresponding options (namely: curl_setopt ())
3. capture the URL and pass it to the browser (namely, curl_exec ())
4. close the curl resource and release the system resource (namely, curl_close ())
CURL submits a get request
Curl: The simplest example of capturing page content (following the four steps above): $ init = curl_init (); $ url = "http://xiongchao.net.cn/"; curl_setopt ($ init, CURLOPT_URL, $ url); $ res = curl_exec ($ init); curl_close ($ init); echo $ res; note: The second step is only the most important part, here you can set some advanced options, such as: CURLOPT_HEADER, CURLOPT_POST and other options curl_setopt () parameter introduction: [http://php.net/manual/zh/function.curl-setopt.php] (http://php.net/manual/zh/function.curl-setopt.php)
CURL submits a post request
The request result is as follows:
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.