1--TEST-- 2Test curl_opt() function with POST parameters 3--CREDITS-- 4Sebastian Deutsch <sebastian.deutsch@9elements.com> 5TestFest 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 16 include 'server.inc'; 17 $host = curl_cli_server_start(); 18 19 // start testing 20 echo '*** Testing curl sending through GET an POST ***' . "\n"; 21 22 $url = "{$host}/get.php?test=getpost&get_param=Hello%20World"; 23 $ch = curl_init(); 24 25 ob_start(); // start output buffering 26 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 27 curl_setopt($ch, CURLOPT_POST, 1); 28 curl_setopt($ch, CURLOPT_POSTFIELDS, "Hello=World&Foo=Bar&Person=John%20Doe"); 29 curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use 30 31 $curl_content = curl_exec($ch); 32 curl_close($ch); 33 34 var_dump( $curl_content ); 35?> 36===DONE=== 37--EXPECT-- 38*** Testing curl sending through GET an POST *** 39string(208) "array(2) { 40 ["test"]=> 41 string(7) "getpost" 42 ["get_param"]=> 43 string(11) "Hello World" 44} 45array(3) { 46 ["Hello"]=> 47 string(5) "World" 48 ["Foo"]=> 49 string(3) "Bar" 50 ["Person"]=> 51 string(8) "John Doe" 52} 53" 54===DONE=== 55