欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

php 虚拟post

程序员文章站 2024-02-01 12:36:34
...
$postData = array();
$postData['data1'] = "testdata1";
$postData['data2'] = "testdata2";
$postData['data3'] = "testdata3";
$url='http://yourdomain/do.php';
$str="";
foreach ($postData as $k=>$v)
{
$str.= "$k=".urlencode($v)."&";
}
$postData=substr($str,0,-1);
$c = curl_init();
curl_setopt($c, CURLOPT_POST, 1);
curl_setopt($c, CURLOPT_HEADER, 0);
curl_setopt($c, CURLOPT_URL,$url);
curl_setopt($c, CURLOPT_POSTFIELDS, $postData);
$result = curl_exec($c);

AD:真正免费,域名+虚机+企业邮箱=0元