php获取文件扩展名的方法

来源:互联网 发布:陪你读书javascript 编辑:程序博客网 时间:2024/05/22 13:01
1、function get_extension($file){
   return substr(strrchr($file, '.'), 1); 
}
2、function get_extension($file){
   return substr($file, strrpos($file, '.')+1);  strrpos获得$file中特定字符最后出现的位置
}
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);
}
0 0