How to use php ftell function

青灯夜游
Release: 2023-02-22 21:32:01
Original
2607 people have browsed it

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

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

Output:

0
15
Copy after login

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!

Related labels:
php
source:php.cn
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