+

PHP SplFileInfo getSize () function

Syntax:
int SplFileInfo::getSize (void)
Parameters:this function takes no parameters.Return Values:this function returns the size of the file in bytes.The programs below illustrate the SplFileInfo::getSize() function in PHP.Program 1:  
// PHP program for illustration
/ / Splfileinfo getSize function $file = new SplFileInfo ( "gfg. txt " ); $gfg = $file -> getSize();  
// Print real path, if exists print ( $gfg . " < / br > " ); $file = new SplFileInfo ( __ FILE__ ); $gfg = $file -> getSize();  
// Print real path if exists print ( $gfg );  
?>
Output:
120 144
Program 2:  
// PHP program to use an array to check multiple files $GFG = array ( "/ home / rajvir / Desktop / GeeksforGeeks / dummy.php" , "/ home / rajvir / Desktop /gfg_code.cpp", "/var/www/html/gfg.txt" , "frame.php"); foreach ( $GFG as & amp; $file_name ) { // create a new SplFile object $file = new SplFileInfo ( $file_name ); $gfg = $file -> getSize(); // Print real path if exists print ( $gfg . "< / br > " ); }
?>
Output:
893 5 51 291
Link: http: // php.net/manual/en/splfileinfo.getsize.php
Get Solution for free from DataCamp guru