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);后会即刻输出返回内容。

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

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

将内容赋值给变量

上一篇:css学习--css基础


下一篇:ASP.NET MVC+EF框架+EasyUI实现权限管理系列(12)-实现用户异步登录和T4模板