php中怎么使用pathinfo()函數解析URL,很多新手對此不是很清楚,為了幫助大家解決這個難題,下面小編將為大家詳細講解,有這方面需求的人可以來學習下,希望你能有所收獲。
1、利用pathinfo解析URL
<? $test = pathinfo("http://localhost/index.php"); print_r($test); ?>
結果如下
Array ( [dirname] => http://localhost //url的路徑 [basename] => index.php //完整文件名 [extension] => php //文件名后綴 [filename] => index //文件名 )
2、利用parse_url()函數解析
<? $test = parse_url("http://localhost/index.php?name=tank&sex=1#top"); print_r($test); ?>
結果如下
Array ( [scheme] => http //使用什么協議 [host] => localhost //主機名 [path] => /index.php //路徑 [query] => name=tank&sex=1 // 所傳的參數 [fragment] => top //后面根的錨點 )
3、使用basename()解析
<? $test = basename("http://localhost/index.php?name=tank&sex=1#top"); echo $test; ?>
結果如下
index.php?name=tank&sex=1#top
看完上述內容是否對您有幫助呢?如果還想對相關知識有進一步的了解或閱讀更多相關文章,請關注創新互聯行業資訊頻道,感謝您對創新互聯網站建設公司,的支持。
當前標題:php中怎么使用pathinfo()函數解析URL-創新互聯
瀏覽路徑:http://www.2m8n56k.cn/article18/dgsedp.html
成都網站建設公司_創新互聯,為您提供動態網站、手機網站建設、網站導航、虛擬主機、搜索引擎優化、網站內鏈
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:[email protected]。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯