Home > Backend Development > PHP Tutorial > Example of using php function to output XML file

Example of using php function to output XML file

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-25 09:10:31
Original
1058 people have browsed it
  1. $conn= new PDO("mysql:dbname=lamp;host=localhost","root","123456");

  2. $sql="select id,username,phone,*** from user";

  3. $pdo=$conn->prepare($sql);
  4. $pdo->execute();
  5. $str='';
  6. $str.='';
  7. //如果内容中有html代码可以使用
  8. while(list($id,$username,$phone,$***)=$pdo->fetch(PDO::FETCH_NUM)){
  9. $str.='';
  10. $str.=''.$username.'';
  11. $str.=''.$phone.'';
  12. $str.='<***>'.$***.'';
  13. $str.='';
  14. }

  15. $str.='';

  16. file_put_contents("user.xml",$str);
  17. header("Content-type:text/xml");
  18. echo $str;
  19. ?>

复制代码


source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template