获取文件拓展名

$file = 'D:\xampp\index.tpl.php';
$ex = get_extension5($file);
echo $ex;

function get_extension1($file)
{
return substr(strrchr($file, '.'), 1);
}

function get_extension2($file)
{
return substr($file, strrpos($file, '.')+1);
}

function get_extension3($file)
{
$array = explode('.', $file);
return end($array);
}

function get_extension4($file)
{
$info = pathinfo($file);
return $info['extension'];
}

function get_extension5($file)
{
return pathinfo($file, PATHINFO_EXTENSION);
}

亲测可用噢~

posted @ 2012-02-06 16:22  yyinsomnia  阅读(188)  评论(0)    收藏  举报