首頁 >後端開發 >php教程 >PHP透過Post提交數據

PHP透過Post提交數據

WBOY
WBOY原創
2016-07-25 08:43:551147瀏覽
  1. $postData = array();
  2. $postData['data1'] = "testdata1";
  3. $postData['data2'] = "testdata2";
  4. $postData['data3'] = "testdata3";
  5. $url='http://yourdomain/do.php';
  6. $str="";
  7. foreach ($postData as $k=>$v)
  8. {
  9. $str.= "$k=".urlencode($v)."&";
  10. }
  11. $postData=substr($str,0,-1);
  12. $c = curl_init();
  13. curl_setopt($c, CURLOPT_POST, 1);
  14. curl_setopt($c, CURLOPT_HEADER, 0);
  15. curl_setopt($c, CURLOPT_URL,$url);
  16. curl_setopt($c, CURLOPT_POSTFIELDS, $postData);
  17. $result = curl_exec($c);
复制代码

PHP、郵政


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