十年網(wǎng)站開發(fā)經(jīng)驗 + 多家企業(yè)客戶 + 靠譜的建站團隊
量身定制 + 運營維護+專業(yè)推廣+無憂售后,網(wǎng)站問題一站解決
php中怎么使用pathinfo()函數(shù)解析URL,很多新手對此不是很清楚,為了幫助大家解決這個難題,下面小編將為大家詳細講解,有這方面需求的人可以來學習下,希望你能有所收獲。
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è)公司,的支持。