PHP Curl Curlopt_returntransfer Parameters Use instances, curl Instance _php tutorial

Source: Internet
Author: User

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 ...

  • Related Article

    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.