i dont understand what is the difference between
CURLOPT_RETURNTRANSFER AND
CURLOPT_BINARYTRANSFER
i wrote a script to check it
<?php
$image_url = "http://localhost/curl/img1.png";
$ch = curl_init();
$timeout = 0;
curl_setopt ($ch, CURLOPT_URL, $image_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
$image = curl_exec($ch);
curl_close($ch);
header("Content-type: image/jpeg");
print $image;
?>
in this case i get the image displayed in the browser if i remove the line
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
i still get the image displayed in the browser.
and now if i remove the line
header("Content-type: image/jpeg");
then iget binary data display in browser(looks like garbage) in both cases whether i remove
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
or i dont remove.
then what difference does this option CURLOPT_BINARYTRANSFER
make?
It looks like CURLOPT_BINARYTRANSFER isn't used by PHP anymore, if I am understanding this PHP bug report and resolution correctly.
https://bugs.php.net/bug.php?id=55635
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