Home > php教程 > php手册 > 用php获取文件扩展名

用php获取文件扩展名

WBOY
Release: 2016-06-06 19:57:29
Original
1002 people have browsed it

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入 用php获取文件扩展名的方法总结,可能不是很全,都是一些常规的方法 ?php //操作的文件 $file = “/Linux/UploadFiles_7565/201211/20121126215424875.gif”; function getext_1($file) { return strto

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入

    用php获取文件扩展名的方法总结,可能不是很全,都是一些常规的方法

   

    //操作的文件

    $file = “/Linux/UploadFiles_7565/201211/20121126215424875.gif”;

    function getext_1($file) {

    return strtolower(trim(substr(strrchr($file, '.'), 1)));

    }

    function getext_2($file) {

    return strtolower(trim(pathinfo($file, PATHINFO_EXTENSION)));

    }

    function getext_3($file) {

    return strtolower(trim(substr($file, strrpos($file, '.')+1)));

    }

    function getext_4($file) {

    return strtolower(trim(array_pop(explode('.', $file))));

    }

    function getext_5($file) {

    $tok = strtok($file, '.');

    while($tok !== false) {

    $return = $tok;

    $tok = strtok('.');

    }

    return strtolower(trim($return));

    }

    ?>

用php获取文件扩展名

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template