php输出xml必须header的解决方法
来源:互联网 发布:孙兴慜数据 编辑:程序博客网 时间:2024/04/28 15:46
本文为大家讲解的是php输出xml必须header的解决方法,以实例形式讲述了php输出xml必须header的情况,是很多php初学者都容易犯的错误,需要的朋友可以参考下
问题描述:
最近在做一个xml输出时发现我们直接使用echo输入的xml文档会提示Error: Object # has no method ‘load'错误的了,后改用了header()输出xml头文件就解决了,下面记录一下。
解决方法:
由于xml长的和txt文件太相似,所以导致我总和txt混为一谈。
现来看看如下代码:
echo '<?xml version="1.0" encoding="UTF-8"?>
<sitemap>
<loc>http://www.adminso.com/</loc>
<lastmod>2013-01-22T11:00:18+08:00</lastmod>
</sitemap>
';
exit;
<sitemap>
<loc>http://www.adminso.com/</loc>
<lastmod>2013-01-22T11:00:18+08:00</lastmod>
</sitemap>
';
exit;
就是这么一段代码,死活输出的xml无法通过xml验证。
提示错误 Error: Object # has no method ‘load'
最后查了半天都和直接放在1.xml里的文件一样
具体代码如下
<?xml version="1.0" encoding="UTF-8"?>
<sitemap>
<loc>http://www.jb51.net/</loc>
<lastmod>2013-01-22T11:00:18+08:00</lastmod>
</sitemap>
<sitemap>
<loc>http://www.jb51.net/</loc>
<lastmod>2013-01-22T11:00:18+08:00</lastmod>
</sitemap>
加个header就好了。 折腾了好几个小时。。。。。
具体代码如下
<?php
header("Content-type:text/xml");
echo '<?xml version="1.0" encoding="UTF-8"?>
<sitemap>
<loc>http://www.jb51.net/</loc>
<lastmod>2013-01-22T11:00:18+08:00</lastmod>
</sitemap>
';
exit;
header("Content-type:text/xml");
echo '<?xml version="1.0" encoding="UTF-8"?>
<sitemap>
<loc>http://www.jb51.net/</loc>
<lastmod>2013-01-22T11:00:18+08:00</lastmod>
</sitemap>
';
exit;
原文地址:http://www.adminso.com/articles/view/92080
(站长搜索- http://www.adminso.com/yuanma -源码下载,更新快,最专业的网站源码下载!)
0 0
- php输出xml必须header的解决方法
- php输出xml必须header的解决方法
- 不缓存页面的解决方法,php header
- php header头部输出
- php header输出类型(备查)
- PHP的header函数头部输出的问题解析
- PHP setcookie() 报 cannot modify header information 错误的解决方法
- php: can not modify header information 的warning解决方法.
- php出现Cannot modify header information问题的解决方法大全
- php出现Cannot modify header information问题的解决方法大全
- php出现Cannot modify header information问题的解决方法
- PHP header 函数不能正常跳转的几种解决方法
- php出现Cannot modify header information问题的解决方法大全
- php出现Cannot modify header information问题的解决方法大全
- PHP出现"Cannot modify header information"警告的解决方法
- PHP setcookie() cannot modify header information 的解决方法
- PHP setcookie() 报 cannot modify header information 错误的解决方法
- PHP经典header错误"Cannot modify header information"的解决方法(转)
- c++运算符重载
- 黑马程序员——第16天下——(API)System,Runtime,Date,Calendar,Math
- 玩转PHP(二)--PHP强大的时间函数:date()
- Service的远程调用
- iText+Flying Saucer生成pdf文档二:给pdf添加页脚
- php输出xml必须header的解决方法
- Unity脚本,平滑跟随目标物体移动和旋转
- 关于<a>标签的 的target属性
- 黑马程序员——Java语言基础下篇
- Matlab 文件读写(I/O)和字符串操作常用命令
- 栈的实现
- FoodsMenu新出美食軸功能手機超炫Food
- java 異常(二)
- OJ循环——迭代法求方程的根