Curl Common features

Source: Internet
Author: User

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

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.