<?php

$path = 'http://www.wstmart.net/doc.html';
$ext = getExt($path);
echo $ext; // 方法1
function getExt($path){
$arr = parse_url($path);
$filename = basename($arr['path']);
$ext = '.'.explode('.',$filename)[1];
return $ext;
} // 方法2
function getExt($path){
return strrchr($path,'.');
} // 方法3
function getExt($path){
return substr($path,strrpos($path,'.'));
} // 方法4
function getExt($path){
return pathinfo($path)['extension'];
} // 方法5
function getExt($path){
return pathinfo($path, PATHINFO_EXTENSION);
}

php获取文件扩展名的更多相关文章

  1. PHP获取文件扩展名的多种方法

    PHP获取文件扩展名的N种方法. 第1种方法: function get_extension($file) { substr(strrchr($file, '.'), 1): } 第2种方法: fun ...

  2. python获取文件扩展名的方法(转)

    主要介绍了python获取文件扩展名的方法,涉及Python针对文件路径的相关操作技巧.具体实现方法如下: 1 2 3 4 import os.path def file_extension(path ...

  3. python获取文件扩展名的方法

    主要介绍了python获取文件扩展名的方法,涉及Python针对文件路径的相关操作技巧 import os.path def file_extension(path): ] print file_ex ...

  4. PHP中获取文件扩展名的N种方法

    PHP中获取文件扩展名的N种方法 从网上收罗的,基本上就以下这几种方式: 第1种方法:function get_extension($file){substr(strrchr($file, '.'), ...

  5. PHP获取文件扩展名五种以上的方法和注释

    在PHP面试中或者考试中会有很大几率碰到写出五种获取文件扩展名的方法,下面是我自己总结的一些方法 $file = ‘需要进行获取扩展名的文件.php’; //第一种,根据.拆分,获取最后一个元素的值f ...

  6. PHP中获取文件扩展名

    function get_extension($file) { return substr(strrchr($file, '.'), 1) ; } function get_extension($fi ...

  7. PHP获取文件扩展名的五种方式

    这是我应聘实习时遇到的一道笔试题: 使用五种以上方式获取一个文件的扩展名. 要求:dir/upload.image.jpg,找出 .jpg 或者 jpg , 必须使用PHP自带的处理函数进行处理,方法 ...

  8. PHP 获取文件扩展名的五种方式

    第一种 substr(strrchr("http://www.xxx.com/public/abc.jpg", '.'), 1); string strrchr('string', ...

  9. ios 获取文件扩展名备忘

    NSString *lastComponent = [cachePath lastPathComponent];              NSString *pathLessFilename = [ ...

随机推荐

  1. C Language Study - gets , getchar &amp; scanf

    慢慢的发现C语言功底是如此的薄弱,被这几个字符输入函数搞糊涂了又~~ 来,再来忧伤一次吧~ 那么.我们从scanf開始: 假如说你要将一串字符输入到一字符数组里,例如以下面程序, char a[2]; ...

  2. HDoj-1250-Hat&#39;s Fibonacci-大数

    Hat's Fibonacci Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  3. iOS开发——基础篇——get和post请求的区别

    HTTP 定义了与服务器交互的不同方法,最常用的有4种,Get.Post.Put.Delete,如果我换一下顺序就好记了,Put(增),Delete(删),Post(改),Get(查),即增删改查,下 ...

  4. web metrics dashboard 数据分析工具 看板 从可视化发现问题 避免sql重复写 调高效率

    <?php$todo = array();$done = array();$h = array();$v = $all['v'];$l = count($v);#19700101 08for ( ...

  5. android.content.ReceiverCallNotAllowedException: 解决方法

    一. android.content.ReceiverCallNotAllowedException: IntentReceiver components are not allowed to reg ...

  6. android 在代码中设置字体颜色 问题

    项目中需要在代码中控制字体颜色 之前是直接引用资源文件  但是不行 tv.setTextColor(R.color.textColor_black); 无效果   后来在网上找了资料发现 要从reso ...

  7. 记录利用CSS完美解决前端图片变形问题

    在头条IT学堂看到CSS完美解决前端图片变形问题的文章,就记录分享下: 一.让图片的宽度或者高度等于容器的宽度或高度,多余的裁掉,然后让图片居中: <style type="text/ ...

  8. 4-3 买家类目-service

    DAO:ProductCategory.Service可以简化一些,叫CategoryService. package com.imooc.sell.service; import com.imooc ...

  9. python/shell脚本报异常^M: bad interpreter: No such file or directory

    问题:在Windows写了一python脚本,上传Linux服务器执行,报异常*****^M: bad interpreter: No such file or directory 原因:window ...

  10. JavaScript编程艺术-第7章代码汇总(2)

    [7.4节] 重回“JavaScript美术馆”代码 ***亲测可用*** HTML: JS: