1<?PHP2 //Create a new curl resource3 $ch=curl_init ();4 //************************************************************************************5 //Set URL and corresponding options6 //Set an array of HTTP header fields. Format: Array (' Content-type:text/plain ', ' content-length:100 ')7 $headers=Array(8"Content-type:application/x-www-form-urlencoded; charset=gb2312 ");9curl_setopt ($ch, Curlopt_httpheader,$headers);Tencurl_setopt ($ch, Curlopt_url, "http://www.baidu.com/"); One //************************************************************************************ A //Request uploaded data Note: To send a file, precede the filename with the @ prefix and use the full path - $data=Array(' name ' = ' Beauty ', ' upload ' = ' @a.zip '); -curl_setopt ($ch, Curlopt_post, 1); thecurl_setopt ($ch, Curlopt_postfields,$data); - //************************************************************************************ - ////Set the curl parameter to ask whether the result is output to the screen, 1 is not returned to the page, 0: Direct display of the hypothetical 0 to 1, then the next $data will need to echo. -curl_setopt ($ch, curlopt_returntransfer,0);//whether the returned information is displayed automatically + //Whether to display the returned HTTP header information -curl_setopt ($ch, Curlopt_header, 1); + //************************************************************************************ A at //After the connection is finished, for example, after calling Curl_close, save the cookie information file. -curl_setopt ($ch, Curlopt_cookiejar,dirname(__file__).‘ /cookie.txt '); - //************************************************************************************ - //************************************************************************************ - -curl_setopt ($curl, Curlopt_post, 1);//Post mode submission incurl_setopt ($curl, Curlopt_postfields,Http_build_query($post));//the information to be submitted - //************************************************************************************ to + the maximum number of seconds that the CURL function is allowed to execute. -curl_setopt ($ch, Curlopt_timeout, 10); the //************************************************************************************ * $curl_setopt ($ch, Curlopt_cookiefile,dirname(__file__).‘ /cookie.txt ');//Read CookiesPanax Notoginseng //************************************************************************************ - the The //curl_getinfo () function returns information about the request after Curl executes, which is useful for debugging and troubleshooting: Get the message after the response + $info= Curl_getinfo ($ch); A //************************************************************************************ the + //Fetch the URL and pass it to the browser - $res= Curl_exec ($ch); $ $ //Turn off the Curl resource and release the system resources -Curl_close ($ch); - Echo"<pre>"; the Print_r($info); - Echo"</pre>";Wuyi the - Wu - About $ - - - A + the - $ the the the the - in the?>
Curl Common features