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

方法1

$arr = explode('.',$filename);
echo array_pop($arr);

方法2

  $ext = strrchr($filename,'.');

方法3

$pos = strrpos($filename, '.');
$ext = substr($filename, $pos);

方法4

$arr = pathinfo($filename);
$ext = $arr['extension'];

方法5

 $str = strrev($filename);
 $ext=strrev(strchr($str,'.',true));