当前位置:Gxlcms > PHP教程 > PHP通过Post提交数据

PHP通过Post提交数据

时间:2021-07-01 10:21:17 帮助过:40人阅读

  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, Post

人气教程排行