THE WORLD'S LARGEST WEB DEVELOPER SITE

PHP ftell() Function


❮ Complete PHP Filesystem Reference

Definition and Usage

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

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

Syntax

ftell(file)

Parameter Description
file Required. Specifies the open file to check

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);
?>

The output of the code above will be:

0
15

❮ Complete PHP Filesystem Reference