Copy CodeThe code is as follows:
$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
The above describes how to display the file extension php file extension Get functions, including how to display the file extension aspects, I hope that the PHP tutorial interested in a friend helpful.