ftell() function returns the current position of the open file. This function returns the current file pointer position. If it fails, returns FALSE.
ftell(file_pointer)
file_pointer − The file pointer created using fopen(). Required.
ftell() function returns the current file pointer position. On failure, returns FALSE.
<?php $file_pointer = fopen("new.txt","r"); echo ftell($file_pointer); fclose($file_pointer); ?>
0
Let us see another example where the current position is changed.
<?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.
10
The above is the detailed content of ftell() function in PHP. For more information, please follow other related articles on the PHP Chinese website!