我正在做curl post但问题是我需要返回空结果,所以我可以为我的ajax请求结果回显另一个值:
下面是代码:
$ch = curl_init("http://www.rankreport.com.au/ajax/add_new_lead");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "lead_company_id=1&lead_business=1234&lead_first_name=asdf&lead_website=12314.com&lead_phone=1234&lead_email=test@test.com&lead_package=seo");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_exec($ch);
curl_close($ch);
echo 'error 3';
当我这样做时,我的结果低于结果:
{"lead_date":1315637343,"lead_company_id":"1","lead_business":"1234","lead_first_name":"asdf","lead_last_name":"","lead_website":"12314.com","lead_phone":"1234","lead_email":"test@test.com","lead_package":"seo"} 3
如何设置curl选项以使其不返回任何curl结果?
答案 0 :(得分:4)
设置CURLOPT_RETURNTRANSFER
:
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$result = curl_exec($ch);
答案 1 :(得分:4)
使用CURLOPT_RETURNTRANSFER = true
将返回的内容作为返回值($ ch)而不是输出。