PHP CURL发布返回结果但我需要空结果

时间:2011-09-10 06:53:27

标签: php curl

我正在做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结果?

2 个答案:

答案 0 :(得分:4)

设置CURLOPT_RETURNTRANSFER

curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$result = curl_exec($ch);

答案 1 :(得分:4)

使用CURLOPT_RETURNTRANSFER = true将返回的内容作为返回值($ ch)而不是输出。