|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-09-12 02:05 UTC] klawd+phpbugs at kamundo dot de
Description:
------------
Setting CURLOPT_STDERR to fopen('php://output', 'w') will write curl debug output.
One would await that setting it to fopen('php://memory', 'w') would store it in the memory and it would be available after a rewind. That is not the case, instead, a warning is raised:
Warning: curl_setopt(): supplied argument is not a valid File-Handle resource in
is php://output a valid file handle resource?
This is very confusing and it should be possible to store the output in the memory.
Test script:
---------------
$handle=curl_init('http://google.com');
curl_setopt($handle, CURLOPT_STDERR, fopen('php://output'));
curl_exec($handle);
curl_setopt($handle, CURLOPT_STDERR, $output=fopen('php://temp'));
curl_exec($handle);
rewind($output);
var_dump($output);
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 18:00:02 2025 UTC |
Anyway, this works here: <?php $handle=curl_init('http://www.google.com/'); curl_setopt($handle, CURLOPT_VERBOSE, true); curl_setopt($handle, CURLOPT_RETURNTRANSFER, true); curl_setopt($handle, CURLOPT_STDERR, $o = fopen('php://temp', "w+")); curl_exec($handle); rewind($o); echo "output: ".stream_get_contents($o); php://memory doesn't work because that stream cannot be cast into a stdio FILE, which curl apparently requires.Fixed test script, now with example.com. $handle=curl_init('http://example.com'); curl_setopt($handle, CURLOPT_VERBOSE, true); curl_setopt($handle, CURLOPT_STDERR, fopen('php://output', "w+")); curl_exec($handle); curl_setopt($handle, CURLOPT_STDERR, $output=fopen('php://temp', "w+")); curl_exec($handle); rewind($output); var_dump(stream_get_contents($output)); Please use var_dump. You will see that it's empty. There should be two outputs: - the one directly written to STDOUT - one with string(n) and wrapped by var_dump's quotes but the latter is empty: string(0) "" I tried both memory and temp