02 php生成xml数据

<?php

class Response_xml{


  /**
  *按xml方式输出通信
  *@param integet $code 状态码
  *@param string $message 提示信息
  *@param array $data 数据
  * return string
  */
    public static function xml(){
       header("Content-Type:text/xml");
       $xml ="<?xml version='1.0' encoding='UTF-8'?>
";
       $xml.="<root>
";
       $xml.="  <code>200</code>
";
       $xml.="  <message>返回数据成功</message>
";
       $xml.="  <data>
";
       $xml.="     <id>1</id>
";
       $xml.="     <name>id</name>
";
       $xml.="  </data>
";
       $xml.="</root>
";

       echo $xml;
       die;
    }
}
Response_xml::xml();
原文地址:https://www.cnblogs.com/hgj123/p/4353674.html