php获取文件后缀的9种方法
获取文件后缀的9种方法
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77 <?php
/**
* Created by PhpStorm.
* User: liuft
* Date: 2016/3/7
* Time: 15:46
*/ //第一种
// function get_extension($file)
// {
// $file = explode('.', $file);
// return end($file);
// }
//第二种 // function get_extension($file)
// {
// return substr(strrchr($file, '.'), 1);
// } //第三种
// function get_extension($file){
// return pathinfo($file)['extension'];
// }
// //第四种
//function get_extension($file)
//{
// return substr($file, strrpos($file, '.') + 1);
//} //第五种
//function get_extension($file)
//{
// $file = preg_split('/\./', $file);
// return end($file);
//} //第六种
// function get_extension($file){
// $file = strrev($file);
// return strrev(substr($file,0,strpos($file,'.')));
// }
// //第七种
// function get_extension($file)
// {
// return pathinfo($file, PATHINFO_EXTENSION);
// }
//
//第八种
// function get_extension($file)
// {
// preg_match_all('/\.[a-zA-Z0-9]+/',$file,$data);
// return !empty($data[0])?substr(end($data[0]),1):'';
// } //第九种
// function get_extension($file){
// return str_replace('.','',strrchr($file,'.'));
// } //暂时想这么多,以后想起来再补充 $file = "http://10.31.63.8:8081/M00/00/09/Ch8_CFaaMLqAO87JAACePvS0ZRk.webp"; $data = get_extension($file); var_export($data);
php获取文件后缀的9种方法的更多相关文章
- PHP获取文件后缀的7中方法
在日常的工作当中我们避免不了要经常获取文件的后缀名,今天我就整理了一下7种获取文件后缀的方法,希望对大家有所帮助. $url = 'http://www.baidu.com/uploads/20185 ...
- C# 根据包含文件的路径和文件的名称的字符串获取文件名称的几种方法
C# 截取带路径的文件名字,扩展名,等等 的几种方法 C#对磁盘IO操作的时候,经常会用到这些,路径,文件,文件名字,文件扩展名. 之前,经常用切割字符串来实现, 可是经常会弄错. 尤其是启始位置,多 ...
- Java获取文件Content-Type的四种方法
HTTP Content-Type在线工具 有时候我们需要获取本地文件的Content-Type,已知 Jdk 自带了三种方式来获取文件类型. 另外还有第三方包 Magic 也提供了API.Magic ...
- 关于Java获取文件路径的几种方法
第一种:File f = new File(this.getClass().getResource("/").getPath()); System.out.println(f); ...
- java项目中获取文件路径的几种方法
// 第一种: 2 File f = new File(this.getClass().getResource("/").getPath()); // 结果: /Users/adm ...
- Java获取文件路径的几种方法
第一种: File f = new File(this.getClass().getResource("/").getPath()); System.out.println(f); ...
- C#获取文件路径的几种方法
//获取启动了应用程序的可执行文件的路径,不包括可执行文件的名称. string str5=Application.StartupPath;//可获得当前执行的exe的文件名. string str1 ...
- android获取文件getMimeType的两种方法
方法1: import java.util.Locale; private static String getSuffix(File file) { if (file == null || !file ...
- php 获取文件后缀最简单的方法
1 <?php 2 $recordingname = '通话录音@18502290616(18502290616)_20171103142448.mp3'; 3 $suffix = end(ex ...
随机推荐
- 【转】C++ 虚函数&纯虚函数&抽象类&接口&虚基类
1. 动态多态 在面向对象语言中,接口的多种不同实现方式即为多态.多态是指,用父类的指针指向子类的实例(对象),然后通过父类的指针调用实际子类的成员函数. 多态性就是允许将子类类型的指针赋值给父类类型 ...
- EAS常用工具类
package com.kingdee.eas.custom; import java.io.File; import java.io.FileNotFoundException; import ja ...
- connect(mapStateToProps,mapDispatchToProps) 的写法
1.写法 import { connect } from 'redux'; import { loading, asyncRequset } from '../../actions/common'; ...
- CentOS下febootstrap自制Docker的CentOS6.6和7.1 Docker镜像
docker image centos febootstrap CentOS 6.6和7.1 Docker自制CentOS镜像 安装: ? 1 yum -y install febootstrap 添 ...
- 利用POI进行Excel的导出
需求:将用户的违约金信息导出为excel表格格式 步骤 1. 数据库中增加按钮的值(注意上级编号要和页面隐藏域中的相等) DZ内容(页面加载时根据SJBH查询数据库内容,读取DZ字段信息并加载样式及方 ...
- Python-Sublime Text3 激活码
1.点击菜单-help-Enter License 2.输入以下内容中的一个 —– BEGIN LICENSE —– Michael Barnes Single User License EA7E- ...
- 表格行与行的间距设置,通过margin无效,要这么设置
CSS border-collapse 属性设置表格的边框是否被合并为一个单一的边框 值 描述 separate 默认值.边框会被分开.不会忽略 border-spacing 和 empty-cell ...
- CGGeometry Reference
CGRectUnionCGRectUnion接受两个CGRect结构体作为参数并且返回一个能够包含这两个矩形的最小矩形.听起来可能没什么,我相信你也可以用几行代码轻松实现这个功能,不过 CGGeome ...
- C++开源库大全(转)
程序员要站在巨人的肩膀上,C++拥有丰富的开源库,这里包括:标准库.Web应用框架.人工智能.数据库.图片处理.机器学习.日志.代码分析等. 标准库 C++ Standard Library:是一系列 ...
- xgboost 自定义目标函数和评估函数
https://zhpmatrix.github.io/2017/06/29/custom-xgboost/ https://www.cnblogs.com/silence-gtx/p/5812012 ...