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

来源:互联网 发布:linux没有安装图形界面 编辑:程序博客网 时间:2024/05/17 05:55

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).’’;?>
阅读全文
0 0
原创粉丝点击