简体   繁体   中英

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:

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 :

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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