PHP curl 得到返回值且不显示在页面上

  • 内容
  • 评论
  • 相关

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.wlphp.com/");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
?>

当执行curl_exec($ch);后会即刻输出返回内容。

救不让它输出而得到它返回的内容的方法。

  1. $c = curl_init();  
  2. curl_setopt($c, CURLOPT_URL, $url);  
  3. //Tell curl to write the response to a variable  
  4. curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);      得到返回值且不显示在页面上
  5. // The maximum number of seconds to allow cURL functions to execute.  
  6. curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 60);    
  7. $buf = curl_exec($c);  

 将内容赋值给变量

本文标签:

版权声明:若无特殊注明,本文皆为《菜鸟站长》原创,转载请保留文章出处。

本文链接:PHP curl 得到返回值且不显示在页面上 - https://wlphp.com/?post=18

发表评论

电子邮件地址不会被公开。 必填项已用*标注