方法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];
}

方法4:

function getExt1($filename)
{
   $arr = explode(\'.\',$filename);
   return array_pop($arr);;
}

方法5:

function getExt2($filename)
{
   $ext = strrchr($filename,\'.\');
   return $ext;
}

方法6:
function getExt3($filename) { $pos = strrpos($filename, \'.\'); $ext = substr($filename, $pos); return $ext; } 方法7: function getExt4($filename) { $arr = pathinfo($filename); $ext = $arr[\'extension\']; return $ext; } 方法8: function getExt5($filename) { $str = strrev($filename); return strrev(strchr($str,\'.\',true)); }

 

 

版权声明:本文为sgm4231原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/sgm4231/p/9821711.html