Home > Article > Backend Development > How to use php ftell function
ftell() function is a built-in function in PHP used to return the current position in an open file. The syntax is ftell(file). This function takes file as a parameter and returns the current file pointer position when successful. If it fails, it returns FALSE.
php How to use the ftell() function?
php The ftell() function opens the current position in the file.
Syntax:
ftell(file)
Parameters:
● file: required. Specifies the open file to be checked.
Return value: Returns the current position of the file pointer, or FALSE if failed.
Let’s take a look at how to use the php ftell() function through an example.
Example
<?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); ?>
Output:
0 15
The above is the detailed content of How to use php ftell function. For more information, please follow other related articles on the PHP Chinese website!