PHP SplFileInfo getExtension () Function

PHP

Syntax:
string SplFileInfo::getExtension (void)
Parameters:this function takes no parameters.Return value:this function returns a string containing the file extension.The following programs illustrate the SplFileInfo::getExtension function in PHP :Program 1:  
// PHP program for illustration
// spExfileinfo getExtension function 
// Create a new SPlFileInfo object $file = new SplFileInfo ( "gfg.php" );  
// Print the result echo $file -> getExtension(); ?>
Exit:
php
Program 2:  
// PHP program to use an array for checking
// multiple files $GFG = array ( "/ home / rajvir / Desktop / GeeksforGeeks / dummy.php " , " / home / rajvir / Desktop / gfg.txt " , "/ var / www / html / gfg.php" , "demo.c"); foreach ( $GFG as & amp; $file_name ) { // Create a new SPlFileInfo object $file = new SplFileInfo ( $file_name ); // Print the result echo $file -> getExtension(). "< / br >" ; }
?>
Exit:
phptxtphpc
Link: http://php.net/manual/en/splfileinfo. getextension.php



Get Solution for free from DataCamp guru