A function to get the file extension_PHP tutorial

WBOY
Release: 2016-07-21 16:02:40
Original
958 people have browsed it

A function to get the file extension
/*
GetFileType
Usage: GetFiletype($filename)
*/

function GetFiletype($Filename) {

if (substr_count($Filename, ".") == 0) { // Check whether there is a . number in the file name.

return; // Return empty

} else if (substr($Filename, -1) == ".") { // Check whether it ends with ., that is, no extension

return; // Return empty

} else {
$FileType = strrchr ($Filename, "."); // Cut from . $FileType = substr ($ Filetype, 1); // Remove. No.
Return $ Filetype; // Return
}
}


$ filename = "testfilename.php4";

$Filename = GetFileType($Filename);

echo $Filename;


http://www.bkjia.com/PHPjc/316537.html

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/316537.htmlTechArticleA function to get the file extension? /* GetFileType usage: GetFiletype($filename) */ function GetFiletype($ Filename) { if (substr_count($Filename, .) == 0) {// Check whether the file name is...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!