- 相關(guān)推薦
php中curl模擬post請求小實(shí)例
使用php curl模擬post請求的小例子,提供大家學(xué)習(xí)一下,就跟隨百分網(wǎng)小編一起去了解下吧,想了解更多相關(guān)信息請持續(xù)關(guān)注我們應(yīng)屆畢業(yè)生考試網(wǎng)!
本機(jī):
復(fù)制代碼 代碼如下:
<?php
$uri = "http://www.a.com/test.php";//這里換成你服務(wù)器的地址
// 參數(shù)數(shù)組
$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);
遠(yuǎn)程服務(wù)器:
復(fù)制代碼 代碼如下:
<?php
if(isset($_POST['name'])){
if(!empty($_POST['name'])){
echo '您好,',$_POST['name'].'!';
}
}
【php中curl模擬post請求小實(shí)例】相關(guān)文章:
php的curl模擬post請求的例子12-17
PHP基于CURL進(jìn)行POST數(shù)據(jù)上傳實(shí)例05-31
PHP中使用cURL實(shí)現(xiàn)Get和Post請求03-07
PHP如何使用curl發(fā)送GET和POST請求03-02
PHP如何用curl發(fā)送GET和POST請求12-15
PHP基于CURL進(jìn)行POST數(shù)據(jù)上傳實(shí)例方法02-15
PHP中使用cURL實(shí)現(xiàn)Get和Post請求的方法05-23
PHP curl之操作實(shí)例01-14