Curl GET request to add header header information

Source: Internet
Author: User

function Get ($url) {    $ch = Curl_init ();    curl_setopt ($ch, Curlopt_httpget, true);    curl_setopt ($ch, Curlopt_returntransfer, 1); TRUE to return the information obtained by CURL_EXEC () as a string instead of a direct output.    $header = [' user-agent:php test '];//Set up a header for your browser Agent    curl_setopt ($ch, Curlopt_httpheader, $header);    curl_setopt ($ch, Curlopt_header, 1); Returns the response header information    curl_setopt ($ch, Curlinfo_header_out, true);//true the request string for the trace handle, which is available from PHP 5.1.3. The key is to allow you to view the request header    curl_setopt ($ch, Curlopt_url, $url);    $result = curl_exec ($ch);    Echo Curl_getinfo ($ch, curlinfo_header_out); The Official document description is the "Send request String", which is actually the header of the request. This is the direct view of the request header, because the above allows to view    curl_close ($ch);    return $result;

Curl Get request to add header header information

Curl GET request to add header header information

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.