curlopt_binarytranfer到底是什么意思? [英] what does curlopt_binarytranfer exactly mean?
问题描述
我不明白
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.
现在,如果我删除行
header("Content-type: image/jpeg");
然后在两种情况下我都将iget二进制数据显示在浏览器中(看起来像垃圾)
curl_setopt($ ch,CURLOPT_BINARYTRANSFER,1);
还是我不删除.
那么此选项CURLOPT_BINARYTRANSFER
有什么不同?
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?
推荐答案
如果我正确理解了此PHP错误报告和解决方案,则PHP似乎不再使用CURLOPT_BINARYTRANSFER.
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
这篇关于curlopt_binarytranfer到底是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!