php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #37075 CURLOPT_BINARYTRANSFER
Submitted: 2006-04-13 23:11 UTC Modified: 2006-04-14 09:37 UTC
From: ceo at l-i-e dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
 [2006-04-13 23:11 UTC] ceo at l-i-e dot com
Description:
------------
I believe something not unlike this should appear in the manual.

I'm not quite up to speed on adding it myself.

Sorry.



CURLOPT_BINARYTRANSER
This option is not documented by the curl package because it is a PHP-specific option.
[nb: This is the crucial reason why I think php.net should document it more than the rest of CURLOPT_*]

It should be set to TRUE when using curl to retrieve binary data such as images, zip files, etc.
It should remain set to FALSE (the default) to retrieve plain text such as HTML or .txt

Example:
<?php
  $curl = curl_init();
  
  //Normal retrieval of text:
  curl_setopt($curl, CURLOPT_URL, 'http://php.net/');
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  $html = curl_exec($curl);
  echo 'html is: ', htmlentities(substr($html, 0, 4)), ' ... ', htmlentities(substr($html, -7)), "<br />\n";
  
  //Retrieval of an image (or other binary data):
  curl_setopt($curl, CURLOPT_URL, 'http://static.php.net/www.php.net/images/php.gif');
  curl_setopt($curl, CURLOPT_BINARYTRANSFER, 1);
  $image = curl_exec($curl);
  echo 'image is: ', htmlentities(substr($image, 0, 4)), "...<br />\n";
  
  //Switch back to normal text:
  curl_setopt($curl, CURLOPT_URL, 'http://php.net/');
  curl_setopt($curl, CURLOPT_BINARYTRANSFER, 1);
  $html = curl_exec($curl);
  echo 'html is: ', htmlentities(substr($html, 0, 4)), ' ... ', htmlentities(substr($html, -7)), "<br />\n";
?>

NOTE:
Some versions of PHP were known to be buggy when switching CURLOPT_BINARYTRANSFER through false/true/false settings in the same curl handle.
See http://bugs.php.net/bug.php?id=37061


Reproduce code:
---------------
I spent a fair amount of time on the curl site trying to find this CURLOPT_BINARYTRANSFER

I also spent a fair amount of Googling and asking on the mailing list.

It took several days of effort to realize that it just plain wasn't really documented well anywhere.


Expected result:
----------------
Since this option is introduced by PHP source and is php-specific I expected to see it documented on php.net



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-14 09:37 UTC] tony2001@php.net
It is documented here:
http://php.net/manual/en/function.curl-setopt.php
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Nov 19 15:00:02 2025 UTC