In this article, you will learn how to get the current position of the file pointer in PHP. The ftell() function in PHP returns the current position of the read/write pointer in an open file.
what is the syntax of the FTELL function in php?
ftell(file)
Parameter | Description |
---|---|
file | Required. Specifies the open file to check |
examples of the FTELL function
Example 1. In this example, we return the current position of the read/write pointer in an open 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);
?>