Home >Backend Development >PHP Tutorial >Solution to the problem that header is required when php outputs xml_PHP tutorial
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:
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:
Just add a header. After struggling for several hours. . . . .
The specific code is as follows
The code is as follows: