亚洲国产日韩欧美在线a乱码,国产精品路线1路线2路线,亚洲视频一区,精品国产自,www狠狠,国产情侣激情在线视频免费看,亚洲成年网站在线观看

php語言

php的curl模擬post請求的例子

時間:2024-12-17 22:53:04 php語言 我要投稿
  • 相關(guān)推薦

php的curl模擬post請求的例子

  本文分享一例php代碼,使用php中的curl函數(shù)模擬post請求,用來學(xué)習(xí)curl函數(shù)的用法,還是不錯的,感興趣的朋友參考下。

  php curl模擬post請求

  在php編程中,curl函數(shù)用的挺多的,本文分享一個簡單的例子。

  1,本機(jī):

  復(fù)制代碼 代碼示例:

  <?php

  $uri = "http://www.jbxue.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);

  2,遠(yuǎn)程服務(wù)器:

  復(fù)制代碼 代碼示例:

  <?php

  if(isset($_POST['name'])){

  if(!empty($_POST['name'])){

  echo '您好,',$_POST['name'].'!';

  }

  }

【php的curl模擬post請求的例子】相關(guān)文章:

php中curl模擬post請求小實(shí)例06-01

PHP如何使用curl發(fā)送GET和POST請求09-10

PHP如何用curl發(fā)送GET和POST請求09-07

PHP中使用cURL實(shí)現(xiàn)Get和Post請求11-13

PHP中使用cURL實(shí)現(xiàn)Get和Post請求的方法10-30

php的curl實(shí)現(xiàn)get和post的代碼07-07

PHP基于CURL進(jìn)行POST數(shù)據(jù)上傳的方法06-19

PHP基于CURL進(jìn)行POST數(shù)據(jù)上傳實(shí)例10-22

PHP的GET和POST請求發(fā)送方法09-27