The ftell() function returns the current position in an open file. The function returns the current file pointer position. On failure, FALSE is returned.
Syntax
ftell(file_pointer)
Parameters
file_pointer − A file pointer created using fopen(). Required.
Return
The ftell() function returns the current file pointer position. On failure, FALSE is returned.
Example
<?php $file_pointer = fopen("new.txt","r"); echo ftell($file_pointer); fclose($file_pointer); ?>
Output
0
Let us see another example, wherein the current position is changed.
Example
<?php $file_pointer = fopen("new.txt","r"); // changing current position fseek($file_pointer,"10"); // displaying current position echo ftell($file_pointer); fclose($file_pointer); ?>
The following is the output. The current position is returned.
Output
10