Copy Code code as follows:
<?php
$file = "/home/lvyaozu/backup_20080115.txt";
For ($i =1 $i < 6; $i + +) {
$func = ' Get_file_ext_ '. $i;
Var_dump ($func ($file));
}
function Get_file_ext_1 ($file) {
Return Strtolower (Trim (substr strrchr ($file, '. '), 1));
}
function Get_file_ext_2 ($file) {
Return Strtolower (Trim (PathInfo ($file, pathinfo_extension));
}
function Get_file_ext_3 ($file) {
Return Strtolower (Trim (substr ($file, Strrpos ($file, '. ') +1));
}
function Get_file_ext_4 ($file) {
Return Strtolower (Trim (Array_pop) (Explode ('; ', $file)));
}
function Get_file_ext_5 ($file) {
$tok = Strtok ($file, '. ');
while ($tok!== false) {
$return = $tok;
$tok = Strtok ('. ');
}
Return Strtolower (Trim ($return));
}
?>
This article from Csdn Blog, reproduced please indicate the source: http://blog.csdn.net/lvyaozu/archive/2009/06/03/4237628.aspx