![]() |
VOOZH | about |
The ftell() function in PHP is an inbuilt function which is used to return the current position in an open file. The file is sent as a parameter to the ftell() function and it returns the current file pointer position on success, or FALSE on failure.
Syntax:
ftell( $file )
Parameters Used: The ftell() function in PHP accepts only one parameter $file. It is a mandatory parameter which specifies the file.
Return Value: It returns the current file pointer position on success, or FALSE on failure.
Exceptions:
Examples:
Input : $myfile = fopen("gfg.txt", "r");
echo ftell($myfile);
Output : 0
Input : $myfile = fopen("gfg.txt", "r");
echo ftell($myfile);
fseek($myfile, "36");
echo ftell($myfile);
Output : 0
36
Below programs illustrate the ftell() function:
Program 1: In the below program the file named gfg.txt contains the following content.
Geeksforgeeks is a portal for geeks!
Output:
0
Program 2: In the below program the file named gfg.txt contains the following content.
Geeksforgeeks is a portal for geeks!
Output:
0 36