Home  >  Article  >  Backend Development  >  PHP实现获取文件后缀名的几种常用方法,_PHP教程

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

WBOY
WBOYOriginal
2016-07-13 09:45:00806browse

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程序设计有所帮助。

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1044849.htmlTechArticlePHP实现获取文件后缀名的几种常用方法, 本文实例讲述了PHP实现获取文件后缀名的几种常用方法。分享给大家供大家参考。具体如下: 方...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn