PHP获取文件后缀名的几种方法

PHP获取文件后缀名的三种方法。

如下:

<? 
PHP获取文件后缀名的几种方法1: 
function get_file_type($filename){ 
$type = substr($filename, strrpos($filename, ".")+1); 
return $type; 
} 
PHP获取文件后缀名的几种方法2: 
function get_file_type($filename) 
{ 
$type = pathinfo($filename); 
$type = strtolower($type["extension"]); 
return $type; 
} 
PHP获取文件后缀名的几种方法3: 
function get_file_type($filename) 
{ 
$type =explode("." , $filename); 
$count=count($type)-1; 
return $type[$count]; 
} 
?>

回顾之前,我们介绍过的多个获取文件扩展名的方法:

php 取得文件扩展名的三种方法(改进版)
php 文件扩展名获取方法汇总
php 获取文件扩展名的三个方法
php 获取文件扩展名的5种方法
一个获取文件扩展名的php自定义函数
php获取文件扩展名的几种方法

条条大道均通向幸福的前方,愿您在脚本学堂,可以找到学习路上的灿烂阳光,伴您度过年轻而多彩的人生好时光。

posted @ 2013-10-15 15:23  一觉睡到天黑黑  阅读(572)  评论(0编辑  收藏  举报