时间:2021-07-01 10:21:17 帮助过:2人阅读
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); // 数据为string类型时,超时; // 如果是array('param' => $data_string)就没问题。 curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_TIMEOUT, 3); curl_exec($ch); curl_close($ch);
$data_string = "ispost=ok&msg=post"; $data = array("ispost"=>"ok","msg"=>"post"); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://localhost/my/www/getdata.php"); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_TIMEOUT, 30); $result = curl_exec($ch); curl_close($ch); echo $result;