learn

Get File Extension

category: Snippets
Created by: Assaad Youssef Abou-Rached

Get File Extension

category: Snippets
Created by: Assaad Youssef Abou-Rached
twitter google+ facebook pinned 

Get File Extension

There are many ways to extract the file extension, the easiest way is to use the built-in function pathinfo().
Since pathinfo() is disabled for secrurity reasons, we will write a simple function that takes a file name as input and returns its extension using substr()

The following code will return: php

Alternative way: return pathinfo($file, PATHINFO_EXTENSION);