本教程操作环境:windows7系统、PHP7.1版、DELL G3电脑
php获取url扩展名的方法
方法1:
复制代码1
2
3
4
5
6
7
<?php
$url="http://localhost/user/order.php";
function get_ext1($url){
return substr(strrchr($url,"."),1);
}
echo get_ext1($url);
?>
登录后复制
方法2:
复制代码1
2
3
4
5
6
7
8
<?php
$url="http://localhost/user/order.php";
function get_ext2($url){
$p=pathinfo($url);//Array ( [dirname] => http://localhost/user [basename] => order.php [extension] => php [filename] => order )
return $p['extension'];
}
echo get_ext2($url);
?>
登录后复制
方法3:
复制代码1
2
3
4
5
6
7
<?php
$url="http://localhost/user/order.php";
function get_ext3($url){
return substr($url,strrpos($url,'.')+1);
}
echo get_ext3($url);
?>
登录后复制
方法4:
复制代码1
2
3
4
5
6
7
8
<?php
$url="http://localhost/user/order.php";
function get_ext4($url){
$arr=explode('.',$url);
return array_pop($arr);
}
echo get_ext4($url);
?>
登录后复制
方法5:
复制代码1
2
3
4
5
6
7
<?php
$url="http://localhost/user/order.php";
function get_ext5($url){
return pathinfo($url,PATHINFO_EXTENSION);
}
echo get_ext5($url);
?>
登录后复制
推荐学习:《PHP视频教程》
以上就是php获取url扩展名的几种方法是什么的详细内容,更多请关注靠谱客其它相关文章!
最后
以上就是安详毛豆最近收集整理的关于php获取url扩展名的几种方法是什么的全部内容,更多相关php获取url扩展名内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复