English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP Filesystem Reference Manual
The ftell() function can return the current position in the opened file. It returns the current file pointer position on success, and false on failure.
int ftell ( resource $handle )
This function can return the position of the file pointer referenced by the handle, which means its offset in the file stream.
<?php $file = fopen("/PhpProject/sample.txt, "r"); //Print Current Position echo ftell($file); //Change Current Position fseek($file, "10"); //Print Current Position Again echo "\n" . ftell($file); fclose($file); ?>
Output Result
0 10
<?php //Open File and Read Data $file = fopen("/PhpProject/sample.txt, "r"); $data = fgets($file, 7); echo ftell($file); fclose($file); ?>
Output Result
6