导航首页 » 技术教程 » PHP:ftell()的用法_Filesystem函数
PHP:ftell()的用法_Filesystem函数 148 2023-12-15   

ftell

(PHP 4, PHP 5)

ftell — 返回文件指针读/写的位置

说明

int ftell ( resource $handle )

返回由 handle 指定的文件指针的位置,也就是文件流中的偏移量。

参数

handle

文件指针必须是有效的,且必须指向一个通过 fopen() 或 popen() 成功打开的文件。在附加模式(加参数 "a" 打开文件)中 ftell() 会返回未定义错误。

返回值

Returns the position of the file pointer referenced by handle as an integer; i.e., its offset into the file stream.

如果出错,返回 FALSE

范例

Example #1 ftell() 例子

<?php

// opens a file and read some data
$fp = fopen("/etc/passwd", "r");
$data = fgets($fp, 12);

// where are we ?
echo ftell($fp); // 11

fclose($fp);

?>

参见

fopen() - 打开文件或者 URL popen() - 打开进程文件指针 fseek() - 在文件指针中定位 rewind() - 倒回文件指针的位置


!!!站长长期在线接!!!

网站、小程序:定制开发/二次开发/仿制开发等

各种疑难杂症解决/定制接口/定制采集等

站长微信:lxwl520520

站长QQ:1737366103