Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

ftell()

Example

In an open file, return the read/write pointer’s current position:

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

Definition and Usage

The read/write pointer’s current location in an open file is returned by the ftell() function.

Syntax

ftell(file)

Parameter Values

 

Parameter

Description

file

Essential. indicates which open file to examine.

Technical Details

Return Value:

The location of the file pointer, or FALSE if it fails.

PHP Version:

4.0+