欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php使用函數(shù)pathinfo()、parse_url()和basename()解析URL

 更新時間:2016年11月25日 09:45:49   投稿:daisy  
眾所周知在PHP中函數(shù)pathinfo()、parse_url()和basename(),這三個都是解析URL的函數(shù),但是也存在一些區(qū)別,下面列舉了一些實例,通過實例更容易理解這三個函數(shù)的使用方法和技巧,有需要的朋友可以參考借鑒,感興趣的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧。

本文主要介紹的是php使用函數(shù)pathinfo() 、parse_url()basename()解析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

總結(jié)

以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作能帶來一定的幫助,如果有疑問大家可以留言交流。

相關(guān)文章

最新評論