|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-10-04 04:10 UTC] iliaa@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 06:00:02 2025 UTC |
Description: ------------ 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: case CURLOPT_RETURNTRANSFER: convert_to_long_ex(zvalue); if (Z_LVAL_PP(zvalue)) { ch->handlers->write->method = PHP_CURL_RETURN; } else { ch->handlers->write->method = PHP_CURL_STDOUT; } break; 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: --------------- <?php $ch = curl_init("http://www.php.net/"); $fp = fopen("example_homepage.txt", "w"); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch,CURLOPT_RETURNTRANSFER,0); curl_exec($ch); curl_close($ch); fclose($fp); ?> Expected result: ---------------- As descripted above i expected the curl output in the file... Actual result: -------------- ...but it occurs in stdout.