belongs to collection: PHP Miscellaneous
print (get) file extension in PHP
Here, we're going to discuss the PHP pathinfo() function which is useful in getting information about a path. This function returns useful information about a file path including file name, extension, directory, and file base name. The below example explains the usage of pathinfo().
$file_data = pathinfo('/path/to/dir/mynewfile.php');
echo $file_data['basename'], "\n";
echo $file_data['dirname'], "\n";
echo $file_data['filename'], "\n";
//returns the current file extension
total answers (1)
start bookmarking useful questions and collections and save it into your
own study-lists, login now to start creating your own collections.