Go ahead and try this :
/**
* @static
* @param $filename
* @param bool $comma
* @return bool|string
*/
public static function getFileExtension($filename, $comma = false) {
if (strrpos($filename, '.')){
$extension = substr($filename, strrpos($filename, '.'));
return $comma ? $extension : substr($extension, 1);
} else
return false;
}
Also, make sure you use this only on upload