php获取文件扩展名
发布时间:2022-09-15 16:46:18 所属栏目:PHP教程 来源:互联网
导读:?php /*** example usage ***/ $filename = filename.blah.txt; /*** get the path info ***/ $info = pathinfo($filename); /*** show the extension ***/ echo $info[extenstion]; //开源代码phpfensi.com ? //第二种方法也基本相同以上,但使用字符串操
<?php /*** example usage ***/ $filename = 'filename.blah.txt'; /*** get the path info ***/ $info = pathinfo($filename); /*** show the extension ***/ echo $info['extenstion']; //开源代码phpfensi.com ?> //第二种方法也基本相同以上,但使用字符串操作获得延长和争夺点(.)字符也。 <?php /*** example usage ***/ $filename = 'filename.blah.txt'; echo getFileExtension($filename); /** * * @Get File extension from file name * * @param string $filename the name of the file * * @return string * **/ function getFileExtension($filename){ return substr($filename, strrpos($filename, '.')); } ?> (编辑:丽水站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |