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