curl_write_stdout.phpt 681 B

123456789101112131415161718192021222324252627282930
  1. --TEST--
  2. Test curl option CURLOPT_FILE with STDOUT handle
  3. --CREDITS--
  4. Mathieu Kooiman <mathieuk@gmail.com>
  5. Dutch UG, TestFest 2009, Utrecht
  6. --DESCRIPTION--
  7. Writes the value 'test' to a temporary file. Use curl to access this file and store the output in another temporary file. Tests the PHP_CURL_FILE case in curl_write().
  8. --EXTENSIONS--
  9. curl
  10. --FILE--
  11. <?php
  12. $log_file = tempnam(sys_get_temp_dir(), 'php-curl-test');
  13. $fp = fopen($log_file, 'w+');
  14. fwrite($fp, "test");
  15. fclose($fp);
  16. $ch = curl_init();
  17. curl_setopt($ch, CURLOPT_FILE, STDOUT);
  18. curl_setopt($ch, CURLOPT_URL, 'file://' . $log_file);
  19. curl_exec($ch);
  20. curl_close($ch);
  21. // cleanup
  22. unlink($log_file);
  23. ?>
  24. --EXPECT--
  25. test