Home > Backend Development > PHP Tutorial > Solution to the problem that header is required when php outputs xml_PHP tutorial

Solution to the problem that header is required when php outputs xml_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:16:38
Original
1261 people have browsed it

Solution to the header required for php output xml

Problem description:

Recently, when doing an xml output, I found that the xml document we input directly using echo will prompt Error: Object # has no method 'load' error. Later, I changed to using header() to output the xml header file and the problem was solved. Record it below.

Solution:

Because the length of xml is too similar to that of txt file, I always confuse it with txt.

Now let’s take a look at the following code:

The code is as follows:

echo '

http://www.jb51.net/
2013-01-22T11:00:18+08:00

';
exit;


Just such a piece of code, the xml output by life and death cannot pass xml verification.
Prompt error Error: Object # has no method ‘load’
Finally, after checking for a long time, it was the same as the file placed directly in 1.xml
The specific code is as follows

Copy the code The code is as follows:



http://www.jb51.net/
2013-01-22T11:00:18+08:00


Just add a header. After struggling for several hours. . . . .
The specific code is as follows

The code is as follows:

header("Content-type:text/xml");
echo '

http://www.jb51.net/
2013-01-22T11:00:18+08:00

';
exit;

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/896777.htmlTechArticleSolution to the header required for php output xml Problem description: Recently when doing an xml output, I found that we directly use echo input The xml document will prompt Error: Object # has no method load' error...
Related labels:
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template