PHP Tutorial - PHP ftell() Function






Definition

The ftell() function returns the current position in an open file.

Syntax

PHP ftell() Function has the following syntax.

ftell(file)

Parameter

ParameterIs RequiredDescription
fileRequired.Open file to check

Return

Returns the current file pointer position, or FALSE on failure.

Example

Returns the current position in an open file


<?php/* w w  w .j a v a 2  s.c  om*/
$file = fopen("test.txt","r");

// print current position
echo ftell($file);

// change current position
fseek($file,"25");

// print current position again
echo "\n";
echo ftell($file);

fclose($file);
?>

The code above generates the following result.