首頁 >後端開發 >php教程 >php curl模拟post请求简单示例

php curl模拟post请求简单示例

WBOY
WBOY原創
2016-06-23 14:35:45808瀏覽

本机:

<?php$uri = "http://tanteng.duapp.com/test.php";// 参数数组$data = array (        'name' => 'tanteng' // 'password' => 'password'); $ch = curl_init ();// print_r($ch);curl_setopt ( $ch, CURLOPT_URL, $uri );curl_setopt ( $ch, CURLOPT_POST, 1 );curl_setopt ( $ch, CURLOPT_HEADER, 0 );curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );curl_setopt ( $ch, CURLOPT_POSTFIELDS, $data );$return = curl_exec ( $ch );curl_close ( $ch ); print_r($return);

远程服务器:

<?phpif(isset($_POST['name'])){    if(!empty($_POST['name'])){        echo '您好,',$_POST['name'].'!';    }}

 

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
上一篇:php的Snoopy类下一篇:php mail类