扫码关注官方订阅号
╰つ ゛思 绪 万 千 , 不 如 努 力 向 前 .ヽ
PHP中获取文件扩展名?-PHP中文网问答-PHP中获取文件扩展名?-PHP中文网问答
围观一下哦,学习一下。
第1种方法:function get_extension($file){ substr(strrchr($file, '.'), 1);}第2种方法:function get_extension($file){ return substr($file, strrpos($file, '.')+1);}第3种方法:function get_extension($file){ return end(explode('.', $file));}第4种方法:function get_extension($file){ $info = pathinfo($file); return $info['extension'];}第5种方法:function get_extension($file){ return pathinfo($file, PATHINFO_EXTENSION);}
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
扫描下载App
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
PHP中获取文件扩展名?-PHP中文网问答-PHP中获取文件扩展名?-PHP中文网问答
围观一下哦,学习一下。
第1种方法:
function get_extension($file){
substr(strrchr($file, '.'), 1);
}
第2种方法:
function get_extension($file){
return substr($file, strrpos($file, '.')+1);
}
第3种方法:
function get_extension($file){
return end(explode('.', $file));
}
第4种方法:
function get_extension($file){
$info = pathinfo($file);
return $info['extension'];
}
第5种方法:
function get_extension($file){
return pathinfo($file, PATHINFO_EXTENSION);
}