Home  >  Article  >  Backend Development  >  How to use php ftell function

How to use php ftell function

青灯夜游
青灯夜游Original
2019-05-28 15:03:482606browse

ftell() function is a built-in function in PHP used to return the current position in an open file. The syntax is ftell(file). This function takes file as a parameter and returns the current file pointer position when successful. If it fails, it returns FALSE.

How to use php ftell function

php How to use the ftell() function?

php The ftell() function opens the current position in the file.

Syntax:

ftell(file)

Parameters:

● file: required. Specifies the open file to be checked.

Return value: Returns the current position of the file pointer, or FALSE if failed.

Let’s take a look at how to use the php ftell() function through an example.

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

Output:

0
15

The above is the detailed content of How to use php ftell function. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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