返回檔案指針讀/寫的位置

ftell

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

ftell返回檔案指針讀/寫的位置

說明

ftell(resource $handle): int

返回由 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

範例

示例 #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);

?>

參見

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *