-
<?phpjson
//首先檢測是否支持curl數組
if (!extension_loaded("curl")) { 瀏覽器
trigger_error("對不起,請開啓curl功能模塊!", E_USER_ERROR);curl
}函數
//構造xmlpost
$xmldata="<?xml version='1.0' encoding='UTF-8'?><group><name>張三</name><age>22</age></group>";測試
//初始一個curl會話url
$curl = curl_init();
//設置url
curl_setopt($curl, CURLOPT_URL,"http://localhost/dealxml.php");
//設置發送方式:
postcurl_setopt($curl, CURLOPT_POST, true);
//設置發送數據
curl_setopt($curl, CURLOPT_POSTFIELDS, $xmldata);
//抓取URL並把它傳遞給瀏覽器
curl_exec($curl);
//關閉cURL資源,而且釋放系統資源
curl_close($curl);
?>
END