A-A+
PHP中获取文件扩展名的几种方法
第一种:
function get_extension($file)
{
substr(strrchr($file, '.'), 1);
}
第二种:
function get_extension($file)
{
return substr($file, strrpos($file, '.')+1);
}
第三种:
function get_extension($file)
{
return end(explode('.', $file));
}
第四种:
function get_extension($file)
{
$info = pathinfo($file);
return $info['extension'];
}
第五种:
function get_extension($file)
{
return pathinfo($file, PATHINFO_EXTENSION);
}