Home  >  Article  >  Backend Development  >  How to generate xml data in php

How to generate xml data in php

不言
不言Original
2018-07-04 16:34:394356browse

This article mainly introduces the method of generating XML data in PHP. It has certain reference value. Now I share it with you. Friends in need can refer to it.

1. There are generally 2 ways to generate XML data in PHP. There are two ways, one is to assemble strings, and the other is to use PHP’s built-in system classes

2. Use PHP’s built-in classes to generate xml data

3. Assemble strings to generate xml data

public function static xml(){
    header("Content-type:text/xml;");
    $xml = "\n";
    $xml .= "\n";
    $xml .= "200\n";
    $xml .= "数据返回成功\n";
    $xml .= "\n";
    $xml .= "1\n";
    $xml .= "yangzl\n";
    $xml .= "\n";
    $xml .= "\n";
    echo $xml;
}

Respine::xml();

The above is the entire content of this article. I hope it will be helpful to everyone's learning. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

About the method of encapsulating data in xml

Explanation of PHP caching technology

The above is the detailed content of How to generate xml data in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn