浏览模式: 普通 | 列表
5月, 2014 | 1

PHP中获取文件扩展名的N种方法

[ 2014-05-27 10:09:29 | 作者: admin ]
PHP中获取文件扩展名的N种方法
从网上收罗的,基本上就以下这几种方式:


第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)
...

阅读全文…
1