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 ...
随机推荐
- java开发中的一些概念名词
1. JavaBeans JavaBean是符合某种规范的Java组件,也就是Java类.它必须满足如下规范: 1)必须有一个零参数的默认构造函数 2)必须有get和set方法,类的字段必须通过get ...
- Python中的关键字的用法
Python有哪些关键字 -Python常用的关键字 and, del, from, not, while, as, elif, global, or, with, assert, else, if, ...
- Linux相关面试题&答案
Linux相关面试题&答案 Linux面试题&答案 假设apache日志格式为:118.78.199.98 – - [09/Jan/2010:00:59:59 +0800] " ...
- vue vuex 大型项目demo示例
1.vuex 动态模块配置 import Vue from 'vue' import Vuex from 'vuex' import store from '@/store'; // 使用Vuex插件 ...
- Ubuntu编码问题
Ubuntu编码问题 root@magus-18:/srv/rorapps/fgcc# rails -v Sorry, command-not-found has crashed! Please fi ...
- Building Vim from source(转)
Compiling Vim from source is actually not that difficult. Here's what you should do: First, install ...
- thinkphp 3.2多语言设置
1.将CheckLangBehavior.class.php(没有的话去下载完整版)文件放到此目录下:\ThinkPHP\Extend\Behavior 2.修改目录下文件Application\Ho ...
- oracle经验小节2
1,instr 函数 在Oracle/PLSQL中,instr函数返回要截取的字符串在源字符串中的位置. 语法如下: instr( string1, string2 [, start_position ...
- EMQ 学习---订阅$SYS主题,捕获客户端上下线消息
acl.config文件定义了可订阅$SYS主题的权限. {allow, {user, "dashboard"}, subscribe, ["$SYS/#"]} ...
- c# 按位与,按位或
在工作中遇到按位或组合权限串.一直不是特别明白.今天终于花了半个下午的时间搞明白其中的道理. 首先每一个权限数都是2的N次方数 如:k1=2 ; //添加 k2=4 ; //删除 k3=8; //修改 ...