当前位置: 移动技术网 > IT编程>开发语言>PHP > PHP实现获取文件后缀名的几种常用方法

PHP实现获取文件后缀名的几种常用方法

2018年05月07日  | 移动技术网IT编程  | 我要评论

本文实例讲述了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程序设计有所帮助。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网