curl_basic_002.phpt 816 B

12345678910111213141516171819202122232425262728293031
  1. --TEST--
  2. Test curl_opt() function with CURLOPT_RETURNTRANSFER parameter set to 1
  3. --CREDITS--
  4. Sebastian Deutsch <sebastian.deutsch@9elements.com>
  5. TestFest 2009 - AFUP - Jean-Marc Fontaine <jmf@durcommefaire.net>
  6. --EXTENSIONS--
  7. curl
  8. --FILE--
  9. <?php
  10. include 'server.inc';
  11. $host = curl_cli_server_start();
  12. // start testing
  13. echo '*** Testing curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); ***' . "\n";
  14. $url = "{$host}/get.inc?test=get";
  15. $ch = curl_init();
  16. ob_start(); // start output buffering
  17. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  18. curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
  19. $curl_content = curl_exec($ch);
  20. curl_close($ch);
  21. var_dump( $curl_content );
  22. ?>
  23. --EXPECT--
  24. *** Testing curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); ***
  25. string(25) "Hello World!
  26. Hello World!"