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