zoukankan      html  css  js  c++  java
  • PHP得出附件扩展名

     1 <?
     2 
     3    $filename = "mypage.asp";
     4  
     5    //1 使用strrchr函数求得
     6    $ext = substr(strrchr($filename, '.'), 1);
     7    echo$ext;
     8    echo"<br>";
     9  
    10    //2 使用strrpos和substr
    11    $ext = substr($filename, strrpos($filename, '.') + 1);
    12    echo$ext;
    13    echo"<br>";
    14  
    15    //3 使用expload 和 end
    16    $ext = end(explode('.', $filename));
    17    echo$ext;
    18    echo"<br>";
    19  
    20    //4 使用 preg_replace 带正则表达式
    21    $ext = preg_replace('/^.*.([^.]+)$/D', '$1', $filename);
    22    echo$ext;
    23    echo"<br>";
    24  
    25    //5 使用pathinfo  
    26    $fileinfo = pathinfo($filename);
    27    $ext = $fileinfo['extension'];
    28    echo$ext;
    29  
    30 ?>
  • 相关阅读:
    数据结构 1
    MyBatis 7
    MyBatis 6
    MyBatis 5
    MaBatis 4
    MyBatis 3
    目录和文件管理
    Linux常用命令精讲
    Sentos7.4安装说明
    RIP
  • 原文地址:https://www.cnblogs.com/jweb/p/4614786.html
Copyright © 2011-2022 走看看