PHP | SplFileObject ftell() Function
The SplFileObject::ftell() function is an inbuilt function of Standard PHP Library (SPL) in PHP which is used to return the position of the file pointer which specifies the current offset in the file.
Syntax:
int SplFileObject::ftell( void )
Parameters: This function does not accept any parameters.
Return values: This function returns the position of the file pointer.
Below Programs illustrate the SplFileObject::ftell() function in PHP:
Program 1:
<?php
$file = new SplFileObject( "gfg.txt" );
$data = $file -> fgets ();
echo $file -> ftell ();
?>
|
Output:
13
Program 2:
<?php
$GFG = array (
"dummy.txt" ,
"gfg.txt" ,
"frame.txt"
);
foreach ( $GFG as & $arr ) {
$file = new SplFileObject( $arr );
$data = $file -> fgets ();
echo $file -> ftell () . "</br>" ;
}
?>
|
Output:
13
15
13
Reference: http://php.net/manual/en/splfileobject.ftell.php
Last Updated :
20 Dec, 2018
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...