Written by Mr Li2023-08-30
php获取复杂网址后缀
帮助手册 Article
<?php
// 要解析的复杂URL
$complexUrl = "https://example.com/path/to/file.html?query=value";
// 解析URL
$urlParts = parse_url($complexUrl);
if (isset($urlParts['path'])) {
// 获取路径部分
$path = $urlParts['path'];
// 使用pathinfo()函数来获取路径的文件信息
$pathInfo = pathinfo($path);
if (isset($pathInfo['extension'])) {
// 提取后缀
$fileExtension = $pathInfo['extension'];
echo "URL后缀: $fileExtension";
} else {
echo "URL没有文件后缀。";
}
} else {
echo "无法解析URL路径。";
}
?>
You may also like
You may be interested
php中的mysql_fetch_row/mysql_fetch_array/mysql_fetch_object的区分区别和使用方法
星期一, 29 7 月 2019By 99122524
1、mysql_fe...
归档
- 2023 年 9 月
- 2023 年 8 月
- 2023 年 7 月
- 2023 年 6 月
- 2023 年 5 月
- 2023 年 4 月
- 2023 年 3 月
- 2023 年 2 月
- 2022 年 11 月
- 2022 年 10 月
- 2022 年 1 月
- 2021 年 12 月
- 2021 年 10 月
- 2021 年 7 月
- 2021 年 4 月
- 2021 年 3 月
- 2021 年 2 月
- 2020 年 11 月
- 2020 年 10 月
- 2020 年 5 月
- 2020 年 4 月
- 2020 年 3 月
- 2020 年 2 月
- 2020 年 1 月
- 2019 年 12 月
- 2019 年 11 月
- 2019 年 10 月
- 2019 年 8 月
- 2019 年 7 月
Calendar
一 | 二 | 三 | 四 | 五 | 六 | 日 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |