ftell()

创建于 2024-12-03 / 27
字体: [默认] [大] [更大]
❮ PHP 文件系统参考手册

实例

返回读/写指针在打开文件中的当前位置:

<?php
$file = fopen("test.txt","r");

// Print current position
echo ftell($file);

// Change current position
fseek($file,"15");

// Print current position again
echo "<br>" . ftell($file);

fclose($file);
?> 运行实例 »

定义和用法

ftell() 函数在打开文件中的当前位置。

该函数返回文件指针的当前位置。若失败,则返回 false。

语法

ftell(file)

参数值

参数 描述
file 必需。规定要检查的已打开文件。

说明

文件指针 file 必须是有效的,且必须指向一个通过 fopen()popen() 成功打开的文件。

在附加模式(加参数 "a" 打开文件)中 ftell() 会返回未定义错误。



技术细节

返回值: 文件指针位置,失败时为 FALSE。
PHP 版本: 4.0+

❮ PHP 文件系统参考手册
0 人点赞过