时间:2021-07-01 10:21:17 帮助过:4人阅读
123
function curlxml($url){
$header[] = "Content-type: text/xml";//定义content-type为xml
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true) ; // 在启用 CURLOPT_RETURNTRANSFER 时候将获取数据返回
$r = curl_exec($ch);
curl_close($ch);
return $r;
}
$url="https://www.123456.com";
$value=curlxml($url);
header('content-type:text/xml;charset=utf-8');
echo $value;