Latest web development tutorials

PHP ftell() 函數

PHP Filesystem 參考手冊 完整的PHP Filesystem參考手冊

定義和用法

ftell() 函數返回在打開文件中的當前位置。

返回文件指針的當前位置,如果失敗則返回FALSE。

語法

ftell(file)

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


實例

<?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);
?>

上面的代碼將輸出:

0
15


PHP Filesystem 參考手冊 完整的PHP Filesystem參考手冊