新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
php中怎么使用pathinfo()函數(shù)解析URL-創(chuàng)新互聯(lián)
php中怎么使用pathinfo()函數(shù)解析URL,很多新手對此不是很清楚,為了幫助大家解決這個難題,下面小編將為大家詳細講解,有這方面需求的人可以來學(xué)習(xí)下,希望你能有所收獲。
1、利用pathinfo解析URL
$test = pathinfo("http://localhost/index.php"); print_r($test); ?>
結(jié)果如下
Array ( [dirname] => http://localhost //url的路徑 [basename] => index.php //完整文件名 [extension] => php //文件名后綴 [filename] => index //文件名 )
2、利用parse_url()函數(shù)解析
$test = parse_url("http://localhost/index.php?name=tank&sex=1#top"); print_r($test); ?>
結(jié)果如下
Array ( [scheme] => http //使用什么協(xié)議 [host] => localhost //主機名 [path] => /index.php //路徑 [query] => name=tank&sex=1 // 所傳的參數(shù) [fragment] => top //后面根的錨點 )
3、使用basename()解析
$test = basename("http://localhost/index.php?name=tank&sex=1#top"); echo $test; ?>
結(jié)果如下
index.php?name=tank&sex=1#top
看完上述內(nèi)容是否對您有幫助呢?如果還想對相關(guān)知識有進一步的了解或閱讀更多相關(guān)文章,請關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝您對創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司,的支持。
分享文章:php中怎么使用pathinfo()函數(shù)解析URL-創(chuàng)新互聯(lián)
URL標(biāo)題:http://www.ef60e0e.cn/article/dgsedp.html