I'm working with cURL, and needing to change my headers after using curl_exec(). But this function displays result automatically. Code:
$ch=curl_init($redir);
$result = curl_exec($ch);
curl_close($ch);
How can I avoid this?
By using curl_setopt(), you can set CURLOPT_RETURNTRANSFER to have curl_exec() return the result instead of echoing it:
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
Direct Output
$ch=curl_init($redir);
curl_exec($ch); // echo ouput
curl_close($ch);
Return Output
$ch=curl_init($redir);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$result = curl_exec($ch); // return ouput
curl_close($ch);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With