设为首页 - 加入收藏 ASP站长网(Aspzz.Cn)- 科技、建站、经验、云计算、5G、大数据,站长网!
热搜: 创业者 数据 手机
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php获取文件扩展名

发布时间:2022-09-15 09:41 所属栏目:121 来源:互联网
导读:?php /*** example usage ***/ $filename = filename.blah.txt; /*** get the path info ***/ $info = pathinfo($filename); /*** show the extension ***/ echo $info[extenstion]; //开源代码phpfensi.com ? //第二种方法也基本相同以上,但使用字符串操作
  <?php
   
  /*** example usage ***/
  $filename = 'filename.blah.txt';
   
  /*** get the path info ***/
  $info = pathinfo($filename);
   
  /*** show the extension ***/
  echo $info['extenstion'];
  //开源代码phpfensi.com
  ?>
   
  //第二种方法也基本相同以上,但使用字符串操作获得延长和争夺点(.)字符也。
   
   
  <?php
   
  /*** example usage ***/
  $filename = 'filename.blah.txt';
   
  echo getFileExtension($filename);
   
  /**
  *
  * @Get File extension from file name
  *
  * @param string $filename the name of the file
  *
  * @return string
  *
  **/
  function getFileExtension($filename){
    return substr($filename, strrpos($filename, '.'));
  }
  ?>

(编辑:ASP站长网)

    网友评论
    推荐文章
      热点阅读