A php function to get the file extension_PHP tutorial

WBOY
Release: 2016-07-13 17:30:36
Original
817 people have browsed it


/*
GetFileType
Usage: GetFiletype($filename)
*/

function GetFiletype($Filename) {

if (substr_count($Filename, ".") == 0) { // Check whether there is a . sign 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 . number
$FileType = substr ($FileType, 1); // Remove . number
return $FileType; // Return
}
}


$Filename = "Testfilename.php4";

$Filename = GetFileType($Filename);

echo $Filename; // Print out php4

?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/509170.htmlTechArticle/* GetFileType usage: GetFiletype($filename) */ function GetFiletype($Filename) { if (substr_count($ Filename, ".") == 0) { // Check whether there is a . sign in the file name. return; // Return empty...
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