(编辑:jimmy 日期: 2024/10/2 浏览:2)
本文主要介绍的是php使用函数pathinfo()
、parse_url()
和basename()
解析URL的实例代码,下面话不多说,直接来看代码
实例代码如下:
1、利用pathinfo解析URL
<"http://localhost/index.php"); print_r($test); "htmlcode">Array ( [dirname] => http://localhost //url的路径 [basename] => index.php //完整文件名 [extension] => php //文件名后缀 [filename] => index //文件名 )2、利用parse_url()函数解析
<"http://localhost/index.php"); print_r($test); "htmlcode">Array ( [scheme] => http //使用什么协议 [host] => localhost //主机名 [path] => /index.php //路径 [query] => name=tank&sex=1 // 所传的参数 [fragment] => top //后面根的锚点 )3、使用basename()解析
<"http://localhost/index.php"); echo $test; "htmlcode">index.php"color: #ff0000">总结以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流。