PHP xml_get_current_byte_index() 函数
PHP 教程
· 2019-01-30 16:56:25
定义和用法
xml_get_current_byte_index() 函数获取 XML 解析器的当前字节索引。
如果成功,该函数则返回当前字节索引。如果失败,则返回 FALSE。
语法
xml_get_current_byte_index(parser)
| 参数 | 描述 |
|---|---|
| parser | 必需。规定要使用的 XML 解析器。 |
实例
<?php
//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))
. "<br />"
. "Line: "
. xml_get_current_line_number($xmlparser)
. "<br />"
. "Column: "
. xml_get_current_column_number($xmlparser)
. "<br />"
. "Byte Index: "
. xml_get_current_byte_index($xmlparser)
. "<br />");
}
}
xml_parser_free($xmlparser);
?>
上面代码的输出如下所示:
ERROR: Mismatched tag Line: 5 Column: 41 Byte Index: 72
点击查看所有 PHP 教程 文章: https://codercto.com/courses/l/5.html
微信营销与运营一册通
何秀芳、葛存山 / 人民邮电出版社 / 2014-10
《微信营销与运营一册通》深入介绍了当今最为火热的话题——微信营销,内容全面、系统和深入。它基于微信的最新版本,从策略、技巧与案例等多角度详细解析了微信的营销与运营,所有内容都是行业经验的结晶,旨在为企业或个人运用微信提供有价值的参考。《微信营销与运营一册通》主要内容如下。 * 5大微信营销利器:书中介绍了5大微信营销利器,包括漂流瓶、二维码、LBS功能、朋友圈和公众平台等。 * 6大微......一起来看看 《微信营销与运营一册通》 这本书的介绍吧!