test.php
/* * test.php
* 这个文件把参数模拟提交到test2.php */
$post_data = array(
'before=a',
'wb_lp=CHJA',
);
$post_data = implode('&',$post_data);
$url='http://localhost/test2.php';
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL,$url);
//传递一个作为HTTP “POST”操作的所有数据的字符串。
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
ob_start();
curl_exec($ch);
$result = ob_get_contents() ;
ob_end_clean();
test2.php
echo '<pre>';
print_r($_GET);
ECHO '<BR>----------<BR>';
print_r($_POST);