最近博主开始深入学习php了,这篇文章主要介绍了PHP实现获取文件后缀名的几种常用方法,通过三种不同的方法实例分析了php获取文件后缀名的实现技巧,分别通过字符串、文件属性及数组等方式实现这一功能,具有一定参考借鉴价值,需要的朋友可以参考下
本文实例讲述了PHP实现获取文件后缀名的几种常用方法。分享给大家供大家参考。具体如下:
方法1:
function get_file_type($filename){
$type = substr($filename, strrpos($filename, ".")+1);
return $type;
}
方法2:
function get_file_type($filename)
{
$type = pathinfo($filename);
$type = strtolower($type["extension"]);
return $type;
}
方法3:
function get_file_type($filename)
{
$type =explode("." , $filename);
$count=count($type)-1;
return $type[$count];
}
希望本文所述对大家的php程序设计有所帮助
赞赏
历史上的文章
- 2017: Linux shell脚本实现检测mysql状态,挂掉立即自动重启( 0)
- 2017: linux定时任务crontab的基本配置格式( 0)
- 2016: 呵呵!腾讯cdn被阿里拦截( 0)
除特别注明外,本站所有文章均为LJY IT BLOG原创,转载请注明出处来自https://www.ljy2345.com/2015/08/php%e5%ae%9e%e7%8e%b0%e8%8e%b7%e5%8f%96%e6%96%87%e4%bb%b6%e5%90%8e%e7%bc%80%e5%90%8d%e7%9a%84%e5%87%a0%e7%a7%8d%e5%b8%b8%e7%94%a8%e6%96%b9%e6%b3%95/
Comments | NOTHING