【发布时间】:2011-05-15 08:36:22
【问题描述】:
我不明白有什么区别
CURLOPT_RETURNTRANSFER AND
CURLOPT_BINARYTRANSFER
我写了一个脚本来检查它
<?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;
?>
在这种情况下,我会在浏览器中显示图像 如果我删除该行
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
我仍然可以在浏览器中显示图像。
现在如果我删除该行
header("Content-type: image/jpeg");
然后在浏览器中显示 iget 二进制数据(看起来像垃圾)在这两种情况下我是否删除
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
或者我不删除。
那么这个选项CURLOPT_BINARYTRANSFER 有什么不同呢?
【问题讨论】: