為什么我按照老師那樣生成xml緩存文件會(huì)報(bào)錯(cuò)?
按照老師視頻中的教學(xué)
public static function xmlApi($code,$message,$data=array()){
if(!is_numeric($code)){
return '';
}
$result=array(
'code'=>$code,
'message'=>$message,
'data'=>$data
);
header("Content-Type:text/xml");
$xml = "<?xml version='1.0' encoding='UTF-8'?>\n";
$xml.= "<root>\n";
$xml.= self::xmlToEncode($result);
$xml.= "</root>";
echo $xml;
}
但是會(huì)報(bào)錯(cuò)Warning: Cannot modify header information - headers already sent by (output started at D:\web\test\jsonORxml\jsonORxml.php:1) in?D:\web\test\jsonORxml\jsonORxml.php?on line?89
2017-07-19
$message='' 給個(gè)默認(rèn)為空的值, self::xmlToEncode($result) 這個(gè)函數(shù)沒(méi)定義就調(diào)用了。