本教程操作环境:windows7系统、PHP7.1版、DELL G3电脑php获取url扩展名的方法方法1:<?php $url="Http://localhost/user/order.php"; functio
本教程操作环境:windows7系统、PHP7.1版、DELL G3电脑
php获取url扩展名的方法
方法1:
<?php
$url="Http://localhost/user/order.php";
function get_ext1($url){
return substr(strrchr($url,"."),1);
}
echo get_ext1($url);
?>
方法2:
<?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:
<?php
$url="http://localhost/user/order.php";
function get_ext3($url){
return substr($url,strrpos($url,'.')+1);
}
echo get_ext3($url);
?>
方法4:
<?php
$url="http://localhost/user/order.php";
function get_ext4($url){
$arr=explode('.',$url);
return array_pop($arr);
}
echo get_ext4($url);
?>
方法5:
<?php
$url="http://localhost/user/order.php";
function get_ext5($url){
return pathinfo($url,PATHINFO_EXTENSION);
}
echo get_ext5($url);
?>
--结束END--
本文标题: php获取url扩展名的几种方法是什么
本文链接: https://www.lsjlt.com/news/1249.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0