bug55767.phpt 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. --TEST--
  2. Test curl_opt() function with POST params from array with a numeric key
  3. --SKIPIF--
  4. <?php
  5. include 'skipinf.inc';
  6. ?>
  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 sending through GET an POST ***' . "\n";
  18. $url = "{$host}/get.php?test=getpost&get_param=Hello%20World";
  19. $ch = curl_init();
  20. ob_start(); // start output buffering
  21. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  22. curl_setopt($ch, CURLOPT_POST, 1);
  23. curl_setopt($ch, CURLOPT_POSTFIELDS, array('Hello'=>'World','Foo'=>'Bar',100=>'John Doe'));
  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 sending through GET an POST ***
  32. string(203) "array(2) {
  33. ["test"]=>
  34. string(7) "getpost"
  35. ["get_param"]=>
  36. string(11) "Hello World"
  37. }
  38. array(3) {
  39. ["Hello"]=>
  40. string(5) "World"
  41. ["Foo"]=>
  42. string(3) "Bar"
  43. [100]=>
  44. string(8) "John Doe"
  45. }
  46. "
  47. ===DONE===