Reputation: 2422
I'm using curl to send a port request without printing the result using this code
$data = array('username' => 'username', 'password' => 'password');
$url = 'http://urlhere';
$ch = curl_init($url);
$postString = http_build_query($data, '', '&');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postString);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// or use this line curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
I've used 1 and true for the last line of code but it always prints the result on the webpage. How to execute curl without outputting the result?
Upvotes: 0
Views: 22
Reputation: 733
must work as i am using same code in my daily projects and getting back data without getting printed
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
Upvotes: 1