PHP获取文件后缀的5种方法

//第1种方法:
function get_extension($file)
{
substr(strrchr($file, '.'), 1);
}
//第2种方法:
function get_extension($file)
{
return substr($file, strrpos($file, '.')+1);
}
//第3种方法:
function get_extension($file)
{
return end(explode('.', $file));
}
//第4种方法:
function get_extension($file)
{
$info = pathinfo($file);
return $info['extension'];
}
//第5种方法:
function get_extension($file)
{
return pathinfo($file, PATHINFO_EXTENSION);
}
转摘https://www.jianshu.com/p/8da4e7e5bd15
posted @ 2019-07-01 13:42  追梦人(菜鸟)  阅读(14212)  评论(0编辑  收藏  举报