首页 > php文件操作 > php获取文件扩展名

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

转载随意~请带上教程地址吧^^

标签:php获取文件 php获取扩展名

相关文章

发表留言