PHP函数---获取文件扩展名/获取文件名

原文链接:http://abeautifulsite.net/2009/03/php-functions-to-get-and-remove-the-file-extension-from-a-string/

get extension function file\_ext()

// Returns only the file extension (without the period).
function file_ext($filename) {
    return preg_replace('/^.*\./', '', $filename);
}

get file name function file\_ext\_strip()

// Returns the file name, less the extension.
function file_ext_strip($filename){
    return preg_replace('/\.[^.]*$/', '', $filename);
}

但是,好像PHP也有自带解决方案:

’;
echo file_ext_strip($filename).’’;
?>