curl_basic_005.phpt 1011 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. --TEST--
  2. Test curl_opt() function with user agent
  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 with user agent ***' . "\n";
  19. $url = "{$host}/get.php?test=useragent";
  20. $ch = curl_init();
  21. ob_start(); // start output buffering
  22. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  23. curl_setopt($ch, CURLOPT_USERAGENT, 'cURL phpt');
  24. curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
  25. $curl_content = curl_exec($ch);
  26. curl_close($ch);
  27. var_dump( $curl_content );
  28. ?>
  29. ===DONE===
  30. --EXPECTF--
  31. *** Testing curl with user agent ***
  32. string(9) "cURL phpt"
  33. ===DONE===