ftell() function in PHP

PHPz
Release: 2023-08-27 11:10:01
forward
1331 people have browsed it

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)
Copy after login

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);
?>
Copy after login

Output

0
Copy after login

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);
?>
Copy after login

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

Output

10
Copy after login

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

Related labels:
source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template