curl_basic_011.phpt 933 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. --TEST--
  2. Test curl_opt() function with COOKIE
  3. --CREDITS--
  4. TestFest 2009 - AFUP - Xavier Gorse <xgorse@elao.com>
  5. --SKIPIF--
  6. <?php include 'skipif.inc'; ?>
  7. --FILE--
  8. <?php
  9. /* Prototype : bool curl_setopt(resource ch, int option, mixed value)
  10. * Description: Set an option for a cURL transfer
  11. * Source code: ext/curl/interface.c
  12. * Alias to functions:
  13. */
  14. include 'server.inc';
  15. $host = curl_cli_server_start();
  16. // start testing
  17. echo '*** Testing curl with cookie ***' . "\n";
  18. $url = "{$host}/get.php?test=cookie";
  19. $ch = curl_init();
  20. ob_start(); // start output buffering
  21. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  22. curl_setopt($ch, CURLOPT_COOKIE, 'foo=bar');
  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 with cookie ***
  31. string(3) "bar"
  32. ===DONE===