您现在的位置: 365建站网 > 建站教程 > PHP 教程 > PHP xml_error_string() 函数

PHP xml_error_string() 函数

此节有 313 人学习过     参与评论

定义和用法

xml_error_string() 函数获取 XML 解析器的错误描述。

语法

</>code

  1. xml_error_string(errorcode)
参数 描述
errorcode 必需。规定要使用的错误代码。该错误码是 xml_get_error_code() 函数的返回值。

说明

返回与 errorcode 描述的错误代码参数对应的文本描述字符串,若没有与之对应的描述,则返回 false。

例子

</>code

  1. <?php
  2. //无效的 xml 文件
  3. $xmlfile = 'test.xml';
  4. $xmlparser = xml_parser_create();
  5. // open a file and read data
  6. $fp = fopen($xmlfile, 'r');
  7. while ($xmldata = fread($fp, 4096))
  8. {
  9. // parse the data chunk
  10. if (!xml_parse($xmlparser,$xmldata,feof($fp)))
  11. {
  12. die( print "ERROR: "
  13. . xml_error_string(xml_get_error_code($xmlparser))
  14. . "<br />"
  15. . "Line: "
  16. . xml_get_current_line_number($xmlparser)
  17. . "<br />"
  18. . "Column: "
  19. . xml_get_current_column_number($xmlparser)
  20. . "<br />");
  21. }
  22. }
  23. xml_parser_free($xmlparser);
  24. ?>

输出:

</>code

  1. ERROR: Mismatched tag
  2. Line: 8
  3. Column: 51

如对本文有疑问,请提交到交流论坛,广大热心网友会为你解答!! 点击进入论坛

发表评论 (313人查看0条评论)
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
昵称:
最新评论
------分隔线----------------------------
PHP 教程目录

快速入口

· 365软件
· 杰创官网
· 建站工具
· 网站大全

其它栏目

· 建站教程
· 365学习

业务咨询

· 技术支持
· 服务时间:9:00-18:00
365建站网二维码

Powered by 365建站网 RSS地图 HTML地图

copyright © 2013-2024 版权所有 鄂ICP备17013400号