public static function getFileExtension($filename)
    {
        $filename = basename($filename);

        // remove possible query string
        $pos = strpos($filename, '?');
        if ($pos !== false) {
            $filename = substr($filename, 0, $pos);
        }

        // retrieve the extension
        $pos = strrpos($filename, '.');
        if ($pos !== false) {
            return strtolower(substr($filename, $pos + 1));
        }

        return '';
    }
public static function getFileExtension($filename)
    {
        $filename = basename($filename);

        // remove possible query string
        $pos = strpos($filename, '?');
        if ($pos !== false) {
            $filename = substr($filename, 0, $pos);
        }

        // retrieve the extension
        $pos = strrpos($filename, '.');
        if ($pos !== false) {
            return strtolower(substr($filename, $pos + 1));
        }

        return '';
    }
public static function getFileExtension ( $ filename ) { $ filename = basename ( $ filename ) ; // remove possible query string $ pos = strpos ( $ filename , '?' ) ; if ( $ pos !== false ) { $ filename = substr ( $ filename , 0 , $ pos ) ; } // retrieve the extension $ pos = strrpos ( $ filename , '.' ) ; if ( $ pos !== false ) { return strtolower ( substr ( $ filename , $ pos + 1 ) ) ; } return '' ; }
Return the extension of a filename, or null if no extension could be found.
The extension is lower-cased and does NOT contain a leading dot.
When no extension can be found, we will return an empty string.

@param string $filename
@return string
Return the extension of a filename or null if no extension could be found . The extension is lower - cased and does NOT contain a leading dot . When no extension can be found we will return an empty string .