1--TEST-- 2curl_setopt basic tests with CURLOPT_STDERR. 3--CREDITS-- 4Paul Sohier 5#phptestfest utrecht 6--SKIPIF-- 7<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> 8--FILE-- 9<?php 10 11$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); 12 13// start testing 14echo "*** Testing curl_setopt with CURLOPT_STDERR\n"; 15 16$temp_file = tempnam(sys_get_temp_dir(), 'CURL_STDERR'); 17 18$handle = fopen($temp_file, 'w'); 19 20$url = "{$host}/"; 21$ch = curl_init(); 22 23curl_setopt($ch, CURLOPT_VERBOSE, 1); 24curl_setopt($ch, CURLOPT_STDERR, $handle); 25$curl_content = curl_exec($ch); 26 27fclose($handle); 28unset($handle); 29var_dump(preg_replace('/[\r\n]/', ' ', file_get_contents($temp_file))); 30@unlink($temp_file); 31 32ob_start(); // start output buffering 33$handle = fopen($temp_file, 'w'); 34curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use 35curl_setopt($ch, CURLOPT_STDERR, $handle); 36$data = curl_exec($ch); 37ob_end_clean(); 38 39fclose($handle); 40unset($handle); 41var_dump(preg_replace('/[\r\n]/', ' ', file_get_contents($temp_file))); 42@unlink($temp_file); 43 44curl_close($ch); 45 46?> 47--EXPECTF-- 48*** Testing curl_setopt with CURLOPT_STDERR 49string(%d) "%S" 50string(%d) "%S" 51* Closing connection #%d 52 53