|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29591 odd behavior changes in php > 4.3.4 by CURLOPT_RETURNTRANSFER
Submitted: 2004-08-09 19:30 UTC Modified: 2004-10-04 04:10 UTC
From: r-two at gmx dot de Assigned:
Status: Not a bug Package: cURL related
PHP Version: Irrelevant OS: linux
Private report: No CVE-ID: None
 [2004-08-09 19:30 UTC] r-two at gmx dot de
I dont know exactly if this is a bug or just misentry in the Documentation. So I simply start with the code responsible for this behavior.

curl.h line 848:
   if (Z_LVAL_PP(zvalue)) {
	ch->handlers->write->method = PHP_CURL_RETURN;
   } else {
	ch->handlers->write->method = PHP_CURL_STDOUT;

as you can see, the write->method is set to STDOUT if the value is 0. This could be very perplexing if the write->method has previously change. (with CURLOPT_FILE in my example)

a simply solution would be to cut the else tree and just change the wirte->method by an none zero value.

a better one could be to rewrite the curl ext in a way that multible write methods can be handeled.

Surely this is not a "real" bug, but either the documentation or the code is wrong and in my opinion it's the code.

Kind regards,
Martin Hoch

Reproduce code:
        $ch = curl_init("");
        $fp = fopen("example_homepage.txt", "w");
        curl_setopt($ch, CURLOPT_FILE, $fp);
        curl_setopt($ch, CURLOPT_HEADER, 0);

Expected result:
As descripted above i expected the curl output in the file...

Actual result:
...but it occurs in stdout.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-10-04 04:10 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

Output options are exclusive. 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jul 24 21:01:28 2024 UTC