php PHP:fun.get_extension

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php PHP:fun.get_extension相关的知识,希望对你有一定的参考价值。

<?php
// PHP获取文件后缀名的几种方法1:
function get_file_type($filename){
    $type = substr($filename, strrpos($filename, ".")+1);
    return $type;
}

// PHP获取文件后缀名的几种方法2:
function get_file_type($filename) 
{ 
     $type = pathinfo($filename); 
     $type = strtolower($type["extension"]); 
     return $type; 
}

// PHP获取文件后缀名的几种方法3:
function get_file_type($filename) 
{ 
     $type =explode("." , $filename); 
     $count=count($type)-1;
     return $type[$count]; 
} 

以上是关于php PHP:fun.get_extension的主要内容,如果未能解决你的问题,请参考以下文章