简体   繁体   English

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

[英]PHP CURL post returning results but I need empty results

I'm doing curl post but the problem is that I need to return empty results so I can echo out another value for my ajax request results: 我正在执行curl发布,但是问题是我需要返回空结果,因此我可以为ajax请求结果回显另一个值:

below is the code: 下面是代码:

$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';

When I do this, I'm getting below results: 当我这样做时,我得到以下结果:

{"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

How do set curl options so that it doesn't return any curl results? 如何设置卷曲选项,以使其不返回任何卷曲结果?

Set CURLOPT_RETURNTRANSFER : 设置CURLOPT_RETURNTRANSFER

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM