Home  >  Q&A  >  body text

PHP中获取文件扩展名?

男神男神2765 days ago864

reply all(2)I'll reply

  • 数据分析师

    数据分析师2017-09-30 23:15:05

    Get file extension in PHP? -PHP Chinese website Q&A-Get file extension in PHP? -PHP Chinese website Q&A

    Please watch and learn.

    reply
    0
  • 迷茫

    迷茫2016-12-20 16:49:58

    第1种方法:
    function get_extension($file){
        substr(strrchr($file, '.'), 1);
    }
    第2种方法:
    function get_extension($file){
        return substr($file, strrpos($file, '.')+1);
    }
    第3种方法:
    function get_extension($file){
        return end(explode('.', $file));
    }
    第4种方法:
    function get_extension($file){
        $info = pathinfo($file);
        return $info['extension'];
    }
    第5种方法:
    function get_extension($file){
        return pathinfo($file, PATHINFO_EXTENSION);
    }

    reply
    1
  • Cancelreply