本人是小白,有错误的地方请指正,勿喷!
在写一个调查问卷的过程中用到了 文件,如想要了解,可以通过以下链接简单学习:http://www.w3school.com.cn/ /
所用工具:phpstudy+notepad++(使用utf-8编码无BOM)
出现的问题如下:最开始的代码如下:我想要 求出去长沙游玩的人数是多少人,
<?php
header('Content-Type: text/ ');
$ str="<? version="1.0" encoding="utf-8"?>
<movies>
<movie>
< >旅游的人数</ >
<id>1</id>
<count>350</count>
<content>长沙</content>
</movie>
<movie>
< >旅游的人数</ >
<id>2</id>
<count>47</count>
<content>张家界</content>
</movie>
<movie>
< >旅游的人数</ >
<id>3</id>
<count>118</count>
<content>上海</content>
</movie>
<movie>
< >旅游的人数</ >
<id>4</id>
<count>80</count>
<content>南京</content>
</movie>
</movies>
";
$ = simple _load_string($ str);
$count0 = $ ->movie[0]->count;
echo $count0;
?>
火狐浏览器上:
解析错误:语法错误
位置:http://localhost:8080/diaocha/2.php
行 1,列 1:350
360浏览器上的错误:
This page contains the following errors:
Below is a rendering of the page up to the first error.
需要改正的地方是:
去掉第一句:header('Content-Type: text/ ');即可。得到350
2、如果你是需要查看 格式的时候
代码如下:
<?php
header('Content-Type: text/ ');
$ str="<? version="1.0" encoding="utf-8"?>
<movies>
<movie>
< >旅游的人数</ >
<id>1</id>
<count>350</count>
<content>长沙</content>
</movie>
<movie>
< >旅游的人数</ >
<id>2</id>
<count>47</count>
<content>张家界</content>
</movie>
<movie>
< >旅游的人数</ >
<id>3</id>
<count>118</count>
<content>上海</content>
</movie>
<movie>
< >旅游的人数</ >
<id>4</id>
<count>80</count>
<content>南京</content>
</movie>
</movies>
";
就可以得出结果:
This file does not appear to have any style information associated with it. The document tree is shown below.
继续阅读与本文标签相同的文章
-
陈冠希竟然和罗永浩联手了!难不成要搞个锤子?当然不是……
2026-05-18栏目: 教程
-
中国最强快递公司,年入300亿,被称作“哪都通”,但国人都很嫌弃
2026-05-18栏目: 教程
-
原厂直播:ANSYS SI/PI/EMI&TI 2019 R3 新功能介绍
2026-05-18栏目: 教程
-
距离死亡不到3个月 Win7被疯狂攻击
2026-05-18栏目: 教程
-
5G商用落地,对OTT和IPTV有哪些影响?
2026-05-18栏目: 教程
