如何顯示檔案副檔名 PHP 檔案副檔名 取得函數

WBOY
發布: 2016-07-29 08:39:58
原創
1063 人瀏覽過

複製程式碼 程式碼如下:


$file = "/home/lvyaozu/backup_20080115.txt
for($i=1; $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, 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));
}
?>
本文來自CSDN博客,轉載請標示出處:http: //blog.csdn.net/lvyaozu/archive/2009/06/03/4237628.aspx

以上就介紹如何顯示檔案副檔名 PHP 檔案副檔名 取得函數,包含如何顯示檔案副檔名方面的內容,希望對PHP教學有興趣的朋友有所幫助。

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!