Annotation of embedaddon/php/ext/curl/tests/curl_basic_003.phpt, revision 1.1
1.1 ! misho 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: --SKIPIF--
! 7: <?php
! 8: if (!extension_loaded("curl")) exit("skip curl extension not loaded");
! 9: if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
! 10: ?>
! 11: --FILE--
! 12: <?php
! 13: /* Prototype : bool curl_setopt(resource ch, int option, mixed value)
! 14: * Description: Set an option for a cURL transfer
! 15: * Source code: ext/curl/interface.c
! 16: * Alias to functions:
! 17: */
! 18:
! 19: $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
! 20:
! 21: // start testing
! 22: echo '*** Testing curl sending through GET an POST ***' . "\n";
! 23:
! 24: $url = "{$host}/get.php?test=getpost&get_param=Hello%20World";
! 25: $ch = curl_init();
! 26:
! 27: ob_start(); // start output buffering
! 28: curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
! 29: curl_setopt($ch, CURLOPT_POST, 1);
! 30: curl_setopt($ch, CURLOPT_POSTFIELDS, "Hello=World&Foo=Bar&Person=John%20Doe");
! 31: curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
! 32:
! 33: $curl_content = curl_exec($ch);
! 34: curl_close($ch);
! 35:
! 36: var_dump( $curl_content );
! 37: ?>
! 38: ===DONE===
! 39: --EXPECTF--
! 40: *** Testing curl sending through GET an POST ***
! 41: string(208) "array(2) {
! 42: ["test"]=>
! 43: string(7) "getpost"
! 44: ["get_param"]=>
! 45: string(11) "Hello World"
! 46: }
! 47: array(3) {
! 48: ["Hello"]=>
! 49: string(5) "World"
! 50: ["Foo"]=>
! 51: string(3) "Bar"
! 52: ["Person"]=>
! 53: string(8) "John Doe"
! 54: }
! 55: "
! 56: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>