PHP Curl initialization and execution method entry-level code, Curl initialization
This is the basis of the collection, preferably familiar with
$ch = Curl_init (); # Sets the URL and returns the result, returns the header curl_setopt ($ch, Curlopt_url, ' http://www.baidu.com/'); curl_setopt ($ch, Curlopt_returntransfer, 1); curl_setopt ($this->ch, Curlopt_header, 1); # Cookie File Settings curl_setopt ($this->ch, Curlopt_cookiejar, $cookie _file); curl_setopt ($this->ch, Curlopt_cookiefile, $cookie _file); # Extra head curl_setopt ($ This->ch, Curlopt_httpheader, Array (' user-agent:mozilla/5.0 '); # set Postcurl_setopt ($ch, Curlopt_post, 1); Curl_ Setopt ($ch, Curlopt_postfields, $poststring); # connection, execution Expiration time curl_setopt ($this->ch, Curlopt_connecttimeout, 5); Curl_ Setopt ($this->ch, Curlopt_timeout, 30); # Whether to follow 301 302curl_setopt ($this->ch, curlopt_followlocation, 1); Curl_ Setopt ($this->ch, Curlopt_maxredirs, ten); # refercurl_setopt ($this->ch, Curlopt_referer, $refer); # HTTP version and port reuse settings curl_setopt ($this->ch, curlopt_http_version, curl_http_version_1_1); curl_setopt ($this->ch, Curlopt_forbid_reuse, 1); # support Httpscurl_setopt ($this->ch, Curlopt_ssl_verifypeer, 0); curl_setopt ($this->ch,Curlopt_ssl_verifyhost, 0); # If a millisecond timeout is required, increase: curl_setopt ($this->ch, curlopt_nosignal, 1); # Execute $response = curl_exec ($ch), if (Curl_errno ($ch)) {curl_error ($ch); Exit ();} Curl_close ($ch);
http://www.bkjia.com/PHPjc/1008002.html www.bkjia.com true http://www.bkjia.com/PHPjc/1008002.html techarticle PHP Curl initialization and execution method entry-level code, Curl initialization This is the basis for the acquisition, preferably familiar with $ch = Curl_init (); # Set the URL and return the results, whether to return to the head curl_ ...