ftell

(PHP 4, PHP 5, PHP 7, PHP 8)

ftell返回文件指針讀/寫(xiě)的位置

說(shuō)明

ftell(resource $handle): int

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

參數(shù)

handle

文件指針必須是有效的,且必須指向一個(gè)通過(guò) fopen()popen() 成功打開(kāi)的文件。在附加模式(加參數(shù) "a" 打開(kāi)文件)中 ftell() 會(huì)返回未定義錯(cuò)誤。

返回值

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

如果出錯(cuò),返回 false。

范例

示例 #1 ftell() 例子

<?php

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

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

fclose($fp);

?>

參見(jiàn)

  • fopen() - 打開(kāi)文件或者 URL
  • popen() - 打開(kāi)進(jìn)程文件指針
  • fseek() - 在文件指針中定位
  • rewind() - 倒回文件指針的位置