curl_basic_003.phpt 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. --TEST--
  2. Test curl_opt() function with POST parameters
  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 sending through GET an POST ***' . "\n";
  14. $url = "{$host}/get.inc?test=getpost&get_param=Hello%20World";
  15. $ch = curl_init();
  16. ob_start(); // start output buffering
  17. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  18. curl_setopt($ch, CURLOPT_POST, 1);
  19. curl_setopt($ch, CURLOPT_POSTFIELDS, "Hello=World&Foo=Bar&Person=John%20Doe");
  20. curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
  21. $curl_content = curl_exec($ch);
  22. curl_close($ch);
  23. var_dump( $curl_content );
  24. ?>
  25. --EXPECT--
  26. *** Testing curl sending through GET an POST ***
  27. string(208) "array(2) {
  28. ["test"]=>
  29. string(7) "getpost"
  30. ["get_param"]=>
  31. string(11) "Hello World"
  32. }
  33. array(3) {
  34. ["Hello"]=>
  35. string(5) "World"
  36. ["Foo"]=>
  37. string(3) "Bar"
  38. ["Person"]=>
  39. string(8) "John Doe"
  40. }
  41. "