curl_basic_002.phpt 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. --SKIPIF--
  7. <?php include 'skipif.inc'; ?>
  8. --FILE--
  9. <?php
  10. /* Prototype : bool curl_setopt(resource ch, int option, mixed value)
  11. * Description: Set an option for a cURL transfer
  12. * Source code: ext/curl/interface.c
  13. * Alias to functions:
  14. */
  15. include 'server.inc';
  16. $host = curl_cli_server_start();
  17. // start testing
  18. echo '*** Testing curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); ***' . "\n";
  19. $url = "{$host}/get.php?test=get";
  20. $ch = curl_init();
  21. ob_start(); // start output buffering
  22. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  23. curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
  24. $curl_content = curl_exec($ch);
  25. curl_close($ch);
  26. var_dump( $curl_content );
  27. ?>
  28. ===DONE===
  29. --EXPECTF--
  30. *** Testing curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); ***
  31. string(25) "Hello World!
  32. Hello World!"
  33. ===DONE===