php curl模拟post请求小实例
本机:
远程服务器:
代码如下:
<?php $uri = "http://www.a.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);
远程服务器:
代码如下:
<?php if(isset($_POST['name'])){ if(!empty($_POST['name'])){ echo '您好,',$_POST['name'].'!'; } }
相关推荐
wmsjlihuan 2020-09-15
shishengsoft 2020-09-15
CyborgLin 2020-08-15
Guanjs0 2020-11-09
poplpsure 2020-08-17
Richardxx 2020-07-26
sunnyhappy0 2020-07-26
knightwatch 2020-07-19
wcqwcq 2020-07-04
chichichi0 2020-06-16
YAruli 2020-06-13
JF0 2020-06-13
84423067 2020-06-12
心丨悦 2020-06-11
zkwgpp 2020-06-04
stoneechogx 2020-06-04
litterfrog 2020-05-30
today0 2020-05-26