php获取文件扩展名
<?php
/*** example usage ***/
$filename = 'filename.blah.txt';
/*** get the path info ***/
$info = pathinfo($filename);
/*** show the extension ***/
echo $info['extenstion'];
//开源代码phprm.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, '.'));
}
永久地址:http://www.phprm.com/wenjian/fs5185.html
转载随意~请带上教程地址吧^^