首页 > 开发 > PHP > 正文

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

2024-05-04 22:03:15
字体:
来源:转载
供稿:网友

php实现了几种常用的获取文件后缀名的方法,使用各种php函数的方法来实现对文件扩展名的获取,我特别喜欢最后一种获取文件扩展名的方法,使用php end函数来获取文件扩展名的最后一个元素的内容。

具体如下:

方法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实现了几种常用的获取文件后缀名的方法,你觉得我们的文章好吗?如果你觉得对你有用,那就请时常来错新技术频道学习吧。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表