+

PHP SplFileInfo isFile () function

Syntax:
bool SplFileInfo::isFile (void)
Parameters:this function takes no parameters.Return Values:this function returns true if the file exists, otherwise - false.The following programs illustrate the SplFileInfo::isFile() function in PHP:Program 1:  
// Program PHP for illustration
// Splfileinfo isFile function  $file = new SplFileInfo (dirname ( " gfg.txt " )); $gfg = $file -> isFile();  
// Print the result var_dump ( $gfg ); echo "< / br >" ; $file = new SplFileInfo ( __ FILE__ ); $gfg = $file -> isFile();  
// Print the result var_dump ( $gfg );  
?>
Output:
bool (false) bool (true)
Program 2:  
// PHP program to use an array for checking
// multiple files $GFG = array ( "/ home / rajvir / Desktop / GeeksforGeeks / dummy.php" , "/ home / rajvir / Desktop / gfg_code.cpp" ,   "/ var / www / html /" , " frame.php "); foreach ( $GFG as & amp; $file_name ) { // Create a new SplFile object $file = new SplFileInfo ( $file_name ); $gfg = $file -> isFile(); // Print the result var_dump ( $gfg ); echo "< / br > " ; }
?>
Output:
bool (false) bool (false) bool (true) bool (false)
Link: http://php.net/manual/en/splfileinfo.isfile.php
Get Solution for free from DataCamp guru