PHP Curl Curlopt_returntransfer Use instances of the parameters, curl instance
Get page content, not output directly to page, curlopt_returntransfer parameter settings
Use PHP curl to get page content or submit data, and sometimes you want the returned content to be stored as a variable instead of being output directly. At this point, you must set the Curlopt_returntransfer option for Curl to 1 or true.
1, Curl get page content, direct output Example:
Copy the Code code as follows:
<?php
$url = ' http://www.bkjia.com ';
$ch = Curl_init ();
curl_setopt ($ch, Curlopt_url, $url);
curl_setopt ($ch, Curlopt_ssl_verifypeer, false);
curl_setopt ($ch, Curlopt_ssl_verifyhost, false);
Curl_exec ($ch);
Curl_close ($ch);
?>
2, Curl get the page content, not directly output example:
Copy the Code code as follows:
<?php
$url = ' http://www.bkjia.com ';
$ch = Curl_init ();
curl_setopt ($ch, Curlopt_url, $url);
curl_setopt ($ch, Curlopt_ssl_verifypeer, false);
curl_setopt ($ch, Curlopt_ssl_verifyhost, false);
curl_setopt ($ch, Curlopt_returntransfer, 1);
$response = curl_exec ($ch); The content has been obtained and is not output to the page.
Curl_close ($ch);
Echo $response;
?>
http://www.bkjia.com/PHPjc/954661.html www.bkjia.com true http://www.bkjia.com/PHPjc/954661.html techarticle php Curl Curlopt_returntransfer parameters of the use of instances, Curl instances get page content, not directly output to the page, curlopt_returntransfer parameter settings using PHP curl to get inside the page ...