日期:2014-05-17 浏览次数:20571 次
$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;