I am trying to save curl VERBOSE information into a string. This is what I tried so far
curl_setopt($ch, CURLOPT_VERBOSE, true);
$fp = fopen("php://memory", 'w+'); //also tried temp
curl_setopt($ch, CURLOPT_STDERR, $fp);
$ret = curl_exec($ch);
rewind($fp);
$verbose = stream_get_contents($fp);
echo "Verbose: ".$verbose;
$verbose holds an empty value
Adding
fputs($fp, "test"); //works if I manually put test string
works so the output is clearly writable and stream_get_contents is the right function
What is that what I am missing here?
Thanks
PS Please do not offer me to use temp files for that. I am looking for a correct way woth IO streams
EDIT
$outputStream = fopen("php://output", 'w');
curl_setopt($ch, CURLOPT_STDERR, $outputStream);
ob_start();
$ret = curl_exec($ch);
$verbose = ob_get_contents();
ob_end_clean();
fclose($outputStream);
curl_close($ch);
echo "Verbose: ".$verbose;
This does not work either as php://output is not catchable by ob_buffer for some reason (bug?)