Php curl packet capture

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.