Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what does curlopt_binarytranfer exactly mean?

Tags:

php

libcurl

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?

like image 908
lovesh Avatar asked Feb 02 '23 18:02

lovesh


1 Answers

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

like image 147
Sean Fahey Avatar answered Feb 05 '23 06:02

Sean Fahey