1.php生成xml数据一般有2种方式, 一个是组装字符串,另一个就是使用php内置的系统类

php生成xml数据

 2.使用php内置类生成xml数据

php生成xml数据

3.拼装字符串生成xml数据

public function static xml(){
    header("Content-type:text/xml;");
    $xml = "<?xml version='1.0' encoding='UTF-8'?>\n";
    $xml .= "<root>\n";
    $xml .= "<code>200</code>\n";
    $xml .= "<message>数据返回成功</message>\n";
    $xml .= "<data>\n";
    $xml .= "<id>1</id>\n";
    $xml .= "<name>yangzl</name>\n";
    $xml .= "</data>\n";
    $xml .= "</root>\n";
    echo $xml;
}

Respine::xml();

 

相关文章:

  • 2022-02-07
  • 2021-10-29
  • 2022-03-05
  • 2022-12-23
  • 2022-12-23
  • 2021-12-23
  • 2021-06-06
  • 2022-01-09
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-19
  • 2022-12-23
  • 2021-11-27
  • 2021-06-04
相关资源
相似解决方案