php解析url几种方式
- 利用$_SERVER内置数组变量
访问:
http:
echo $_SERVER['QUERY_STRING'];
返回:
m=admin&c=index&a=lists&catid=1&page=1
echo $_SERVER["REQUEST_URI"];
返回:
/test.php?m=admin&c=index&a=lists&catid=1&page=1
- 利用pathinfo内置函数
echo "<pre>";
$url = 'http://localhost/test.php?m=admin&c=index&a=lists&catid=1&page=1#top';
var_export(pathinfo($url));
返回:
array (
'dirname' => 'http://localhost',
'basename' => 'test.php?m=admin&c=index&a=lists&catid=1&page=1#top',
'extension' => 'php?m=admin&c=index&a=lists&catid=1&page=1#top',
'filename' => 'test',
)
- 利用parse_url内置函数
echo