php getbyte,PHP xml_get_current_byte_index() 函数

PHP xml_get_current_byte_index() 函数

bbc737cd241b5bce4da46547cb17dc8c.png 完整的 PHP XML 参考手册

定义和用法

xml_get_current_byte_index() 函数获取 XML 解析器的当前字节索引。

如果成功,该函数则返回当前字节索引。如果失败,则返回 FALSE。

语法

xml_get_current_byte_index(parser)

参数

描述

parser

必需。规定要使用的 XML 解析器。

实例

//invalid xml file

$xmlfile = 'test.xml';

$xmlparser = xml_parser_create();

// open a file and read data

$fp = fopen($xmlfile, 'r');

while ($xmldata = fread($fp, 4096))

{

// parse the data chunk

if (!xml_parse($xmlparser,$xmldata,feof($fp)))

{

die( print "ERROR: "

. xml_error_string(xml_get_error_code($xmlparser))

. "
"

. "Line: "

. xml_get_current_line_number($xmlparser)

. "
"

. "Column: "

. xml_get_current_column_number($xmlparser)

. "
"

. "Byte Index: "

. xml_get_current_byte_index($xmlparser)

. "
");

}

}

xml_parser_free($xmlparser);

?>

上面代码的输出如下所示:

ERROR: Mismatched tag

Line: 5

Column: 41

Byte Index: 72

bbc737cd241b5bce4da46547cb17dc8c.png 完整的 PHP XML 参考手册

原文链接:https://rumenz.com/php/func_xml_get_current_byte_index.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值