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