让 php curl_exec直接返回字符串
如果想php 的curl函数直接返回字符串,而不是存储到某个文件,应该怎么做呢?$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);
关键是:curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
这一句。
页:
[1]