您的位置:首页 > 编程语言 > PHP开发

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

2015-08-08 00:00 1851 查看

本文实例讲述了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程序设计有所帮助。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: