Home > Backend Development > PHP Tutorial > PHP读取XML文件出有关问题

PHP读取XML文件出有关问题

WBOY
Release: 2016-06-13 10:19:19
Original
871 people have browsed it

PHP读取XML文件出问题
截取片段:
  $dom = new DOMDocument;
$dom -> load("Practice.xml"); //这一行出错
  .....
  .....
  ?>
错误提示:
  Warning: DOMDocument::load() [domdocument.load]: Input is not proper UTF-8, 
  indicate encoding ! Bytes: ......

在Practice.xml文档中,我使用了encoding = "UTF-8",但是还是不能出现中文内容,不知道问题出哪儿了?

------解决方案--------------------
Practice.xml也要用UTF-8编码
------解决方案--------------------
Practice.xml 需要在保存时选择 utf-8 编码
------解决方案--------------------
不是要你把 php 文件保存为 utf-8 的
而是要你把 xml 文件保存为 utf-8 的
既然 xml 文件已经声明

如果内容不是 utf-8 的,当然会报错

你也可以修改 xml 的语言声明

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template