PHP 5种方式获取文件后缀名
<?php
header("content-type:text/html;charset=utf-8");
function get_ext1($filename)
{
return strrchr($filename,'.');
} function get_ext2($filename){
return substr($filename,strrpos($filename,'.')+1);
} function get_ext3($filename){
return array_pop(explode('.',$filename));
} function get_ext4($filename){
return pathinfo($filename,PATHINFO_EXTENSION);
} function get_ext5($filename){
return strrev(substr(strrev($filename),0,strpos(strrev($filename),'.')));
} $filename = "qqq.php"; echo get_ext1($filename)."<br/>";
echo get_ext2($filename)."<br/>";
echo get_ext3($filename)."<br/>";
echo get_ext4($filename)."<br/>";
echo get_ext5($filename)."<br/>"; ?>
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQUAAAC0CAIAAAASFa6iAAAO5UlEQVR4nO3d61cTZwIG8Pl7errL7rbbq1bbbl3b1a5WW7WKRRRUxAtirVoFbK0WT7fxUi+AjVuUdAMYEwEBQyAQgoISUZIggsRwCblgyAWFJJ6T/TAm7yQzmQSINfE8v/N8kGFmAsf3YWYY5g1V12VBEIQOVX/HiiAIHWr/yXIEQehQ7smnCILQoawuH4IgdCiLy4cgCB3K4vIiCEKHMju9sWfU4dEZrE237smaOsV1baVXmkuvNIvr2mRNnY03e3QG66jDM60dIkhCJdY+GG0TTbfulVWrLsnb2+4O3BscM1hcZseU2TFlsLj0Rlvb3YHLDR2lV5qbbt0z2iZe+DeGIDMIZXb6+DPq8LZ2PSirVslv6IxWt839lCdDY48VHT2lV5qVnfdH7FNRd44gCRVq1OnlyUPbhERxU9p0a2DUaXP7YozR6q5uuV0pbzdY3fz7R5CECjXq8EZKj/GRqEbddLPH6vTaXL5pxer0qm73/yS8fKrsqlDSGPecEtVWNd9GkPgmYh8eWiYuXGm53m2YbhOY0fQMl8qURot7NjvhTHG5/ClAvFGjTh87Joe34lp7Q7ue/2ohljRr+srrb4w6PLPfFTPFFXI/QLxRJoeXHWXn/Up5u8Xpjcs9P5myU9HRE9/7iMXlce6DzWaL7w4hGVEjDm9YBiwT56XKPpMjlvt558ou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PgAQ6AMAgT4AEOgDAIE+ABDoAwCBPgAQ6AMAgT4AEOgDAIE+ABD/B3lEi/yK9vBJAAAAAElFTkSuQmCC" alt="" />
PHP 5种方式获取文件后缀名的更多相关文章
- PHP获取文件后缀名的三种方法
如下: <? PHP获取文件后缀名的几种方法1: function get_file_type($filename){ $type = substr($filename, strrpos($fi ...
- PHP获取文件后缀名
PHP获取文件后缀名是PHP学习者常见的一种操作,无论是在面试过程中还是PHP新手自学中.PHP获取文件后缀名都是很普遍的需要掌握的一个知识点. 下面我们就给大家总结介绍PHP获取文件扩展名也就是后缀 ...
- [Java] 03 String获取文件后缀名,判断文件是否合法
package test.string; import java.util.Arrays; import java.util.List; public class GetFileType { priv ...
- java 获取文件后缀名(文件类型)
java 获取文件后缀名(文件类型) CreateTime--2018年5月23日09:16:31 Author:Marydon // 获取文件名的后缀名(文件类型) String oldFile ...
- javascript获取文件后缀名
javascript获取文件后缀名:在需要验证文件格式的时候,首先就要获得文件的格式,下面是一个通过正则表达式获取文件后缀名的一个简单实例. function validate(){ var impo ...
- python应用-获取文件后缀名
def get_suffix(filename,has_dot=False): """ 获取文件后缀名 :param filename: 文件名 :param has_d ...
- VC获取文件后缀名
VC获取文件后缀名 2011-07-28 10:30:50| 分类: Visual C++ and O | 标签: |举报 |字号大中小 订阅 1. CString GetSuffix(C ...
- C/C++获取文件后缀名并且比较
以下这段是VC中过去文件后缀名的方法 1.CString GetSuffix(CString strFileName) { return strFileName.Right(strFi ...
- php 获取文件后缀名
$file_ext = strtolower(substr(strrchr($upload_file, '.'), 1)); strrchr:查找指定字符在字符串中的最后一次出现 string str ...
随机推荐
- Oracle学习笔记之六(DDL:表、索引、视图、同义词、序列操作相关SQL)
下面这些基本的SQL语句应该熟悉,能够灵活运用.最好在不查资料的情况下,能够写出如下的任何代码. 1. 数据表操作相关 --创建表 create table STUDENTS( STUNO ) not ...
- Modelsim编译Xilinx器件库的另一种方法
由 xooo 于 星期五, 09/18/2015 - 15:35 发表 以前在用modelsim对Xilinx进行器件库编译时,我用的比较多的是直接在ISE中编译器件库,感觉很方便简单,就是编译时间有 ...
- Ribbon重试机制与Hystrix熔断机制的配置问题
Ribbon超时与Hystrix超时问题,为了确保Ribbon重试的时候不被熔断,我们就需要让Hystrix的超时时间大于Ribbon的超时时间,否则Hystrix命令超时后,该命令直接熔断,重试机制 ...
- ELK的索引的坑——Kibana的图形化(Tile Map)
如果想通过ELK展示地图, 需要将索引名称修改为:logstash*的格式 否则location字段不会修改成geo_point的形式. 详情参考:http://blog.csdn.net/yangg ...
- java.io.PrintWriter 中 write() 与 print() 的区别
最终都是重写了抽象类Writer里面的write方法print方法可以将各种类型的数据转换成字符串的形式输出.重载的write方法只能输出字符.字符数组.字符串等与字符相关的数据.
- 百度编辑器UEditor不能插入音频视频的解决方法
引用:https://my.oschina.net/u/379795/blog/787985 xssFilter导致插入视频异常,编辑器在切换源码的过程中过滤掉img的_url属性(用来存储视频url ...
- iOS网络NSURLConnection使用详解
一.整体介绍 NSURLConnection是苹果提供的原生网络访问类,但是苹果很快会将其废弃,且由NSURLSession(iOS7以后)来替代.目前使用最广泛的第三方网络框架AFNetworkin ...
- kafka的分区模式?
当别人问这个问题的时候,别人肯定是想你是否看过源码.是否针对不同场景改过kafka的分区模式 这是别人最想知道的是,你的message如何负载均衡的发送给topic的partition 我们用kafk ...
- redis 最优雅的错误提示
Exception in thread "main" redis.clients.jedis.exceptions.JedisDataException: DENIED Redis ...
- Windows C++ 非递归式(stack)深度优先遍历目录
#include <Windows.h> #include <cstdio> #include <cstring> #include <string> ...