header('Content-Type:text/xml');中的:是英文下的:,不是中文下的:否则php会当做没有使用header('Content-Type:text/xml');仍然按照html解析下面的xml文档了
下面例子是正确的,
<?php
/****XML文档
****/
header('Content-Type:text/xml');
?>
<?xml version='1.0' encoding='utf-8'?>
<bookstore><book bid='b008'><title>天龙八部</title><intro>人生太苦了</intro></book></bookstore>
执行结果如下:
如果代码如下:(与上面不同的只是::)
<?php
/****
XML文档
****/
header('Content-Type:text/xml');
?>
<?xml version='1.0' encoding='utf-8'?>
<bookstore><book bid='b008'><title>天龙八部</title><intro>人生太苦了</intro></book></bookstore>
执行结果是: