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:
<?php$url = ' http://52php.cnblogs.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:
<?php$url = ' http://52php.cnblogs.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;? >
PHP Curl Get page content, not directly output to the page, curlopt_returntransfer parameter settings