Home  >  Article  >  Backend Development  >  ftell() function in PHP

ftell() function in PHP

PHPz
PHPzforward
2023-08-27 11:09:091159browse

ftell() function in PHP

ftell() function returns the current position of the open file. This function returns the current file pointer position. If it fails, returns FALSE.

Syntax

ftell(file_pointer)

Parameters

  • file_pointer − The file pointer created using fopen(). Required.

Return value

ftell() function returns the current file pointer position. On failure, returns FALSE.

Example

<?php
   $file_pointer = fopen("new.txt","r");
   echo ftell($file_pointer);
   fclose($file_pointer);
?>

Output

0

Let us see another example where the current position is changed.

Example

<?php
   $file_pointer = fopen("new.txt","r");
   // changing current position
   fseek($file_pointer,"10");
   // displaying current position
   echo ftell($file_pointer);
   fclose($file_pointer);
?>

The following is the output. The current position is returned.

Output

10

The above is the detailed content of ftell() function in PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete