方法1:
function
getExt1(
$filename
)
{
$arr
=
explode
(
'.'
,
$filename
);
return
array_pop
(
$arr
);;
}
方法2:
function
getExt2(
$filename
)
{
$ext
=
strrchr
(
$filename
,
'.'
);
return
$ext
;
}
方法3:
function
getExt3(
$filename
)
{
$pos
=
strrpos
(
$filename
,
'.'
);
$ext
=
substr
(
$filename
,
$pos
);
return
$ext
;
}
方法4:
function
getExt4(
$filename
)
{
$arr
=
pathinfo
(
$filename
);
$ext
=
$arr
[
'extension'
];
return
$ext
;
}
方法5:
function
getExt5(
$filename
)
{
$str
=
strrev
(
$filename
);
return
strrev
(
strchr
(
$str
,
'.'
,true));
}