php获取文件扩展名的三个方法
时间:2021-07-01 10:21:17
帮助过:15人阅读
//取得文件的扩展名 - //by bbs.it-home.org
- //方法1
- function get_ext_file_1($file_name)
- {
- $retval = "";
- $pt = strrpos($file_name, ".");
- if ($pt) $retval=substr($file_name, $pt+1, strlen($file_name) - $pt);
- return ($retval);
- }
//方法2 - function get_ext_file_2($file_name)
- {
- $get_ext_file = pathinfo($file_name);
- $get_ext_file = strtolower($get_ext_file["extension"]);
- return $get_ext_file;
- }
//方法3 - function get_ext_file_3($file_name)
- {
- $get_ext_file =explode("." , $file_name);
- $va=count($get_ext_file)-1;
- return $get_ext_file[$va];
- }
- ?>
|