<?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/>"; ?>
PHP 5种方式获取文件后缀名
最新推荐文章于 2023-06-11 10:07:53 发布