总有人间一两风,填我十万八千梦

PHP xml_error_string 用法 手册 | 示例代码

PHP开发手册 归档 394℃ 0评论

xml_error_string

(PHP 4, PHP 5, PHP 7)

xml_error_string获取 XML 解析器的错误字符串

说明

xml_error_string ( int $code ) : string

根据给定的 code 获得 XML 解析器错误字符串。

参数

code

xml_get_error_code() 返回的错误代码。

返回值

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

参见

用户贡献的笔记

greg at getnetez dot com

Two notes in one.

Here is the combination of xml_get_error_code() and xml_error_string() to get the error printout as an echo response

Also, I tested before and after xml_parser_free() -- as expected, the error is indeed cleared with the free() so check your error before calling xml_parser_free()

Pushing a deadline or I would add in sample faulted xml for full p.o.c.

somebody else want to step up for that??

G

<?php
$p
= xml_parser_create();
xml_parse_into_struct($p, $data, $vals, $index);
//This call prints error
echo 'ERROR if any '.xml_error_string(xml_get_error_code($p));
xml_parser_free($p);
echo
"Index array\n";
print_r($index);
echo
"\nVals array\n";
print_r($vals);
//No Error left here to be printed
echo 'ERROR if any '.xml_error_string(xml_get_error_code($p));
exit;
?>

转载请注明:悠然品鉴 » PHP xml_error_string 用法 手册 | 示例代码

喜欢 (0)or分享 (0)
发表我的评论
取消评论

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址