你能在例子中描述一下吗?
我知道这是一个老问题,但也许我的回答对你或其他人有所帮助. WRITEFUNCTION用于处理文本,因为它是流式传输或基于某些条件中止下载.这是一个简单地将所有文本都放入大写字母的示例:
原文链接:https://www.f2er.com/php/138023.htmlfunction get_html($url){ $ch = curl_init(); $obj = $this;//create an object variable to access class functions and variables $this->result = ''; $callback = function ($ch,$str) use ($obj) { $obj->result .= strtoupper($str); return strlen($str);//return the exact length }; curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_HEADER,0); curl_setopt($ch,CURLOPT_WRITEFUNCTION,$callback); curl_exec($ch); curl_close($ch); return $this->result; }
要查看我如何使用它,请查看此链接:Parallel cURL Request with WRITEFUNCTION Callback.