您现在的位置是:首页 > PHP函数

李清波 2021-06-17 PHP函数 1608 复制当前网址

xml_get_error_code



PHP xml_get_error_code() 函数

定义和用法

xml_get_error_code() 函数获取 XML 解析器错误代码。


如果成功,则返回错误代码。否则,返回 false。


语法

xml_get_error_code(parser)


参数描述
parser必需。规定要使用的 XML 解析器。


例子

<?php//无效的 xml 文件$xmlfile = test.xml;

$xmlparser = xml_parser_create();// 打开文件并读取数据$fp = fopen($xmlfile, r);
while ($xmldata = fread($fp, 4096)) 
  {
  // parse the data chunk
  if (!xml_parse($xmlparser,$xmldata,feof($fp))) 
    {
    die( print "ERROR: "
    . xml_get_error_code($xmlparser)
    . "<br />"
    . "Line: "
    . xml_get_current_line_number($xmlparser)
    . "<br />"
    . "Column: "
    . xml_get_current_column_number($xmlparser)
    . "<br />");
    }
  }

xml_parser_free($xmlparser);
?>

输出:

ERROR: 76
Line: 8
Column: 61


文章来源:http://liqingbo.com/blog-898.html

上一篇:xml_parse

下一篇:xml_get_current_line_number

评论