using parse_url function we can get all components of url
$url = 'http://testurl.com/path?arg=value#anchor'; echo ''; print_r(parse_url($url));
o/p
Array ( [scheme] => http [host] => testurl.com [path] => /path [query] => arg=value&val=php&cat=technology [fragment] => anchor )
How to parse the query string from above snippet.
$url = 'http://testurl.com/path?arg=value&val=php&cat=technology#anchor'; $p_url = parse_url($url); Syntax : //void parse_str ( string $str [, array &$arr ] ) parse_str($p_url['query'],$op);
// or else you can get the query string using $op = $_SERVER['QUERY_STRING'] print_r($op);
Array ( [arg] => value [val] => php [cat] => technology )
Learn to Develop an iPhone or iPad App in 4 Weeks Learn the latest and greatest markup language in the market with Robin Nixon(HTML & HTML5) Now $29 Only(75% Off)
using parse_url function we
Wed, 06/30/2010 - 16:15 — bandariusing parse_url function we can get all components of url
$url = 'http://testurl.com/path?arg=value#anchor';
echo '';
print_r(parse_url($url));
o/p
Array
(
[scheme] => http
[host] => testurl.com
[path] => /path
[query] => arg=value&val=php&cat=technology
[fragment] => anchor
)
How to parse the query
Wed, 06/30/2010 - 16:24 — adminHow to parse the query string from above snippet.
$url = 'http://testurl.com/path?arg=value&val=php&cat=technology#anchor';
$p_url = parse_url($url);
Syntax : //void parse_str ( string $str [, array &$arr ] )
parse_str($p_url['query'],$op);
// or else you can get the query string using $op = $_SERVER['QUERY_STRING']
print_r($op);
o/p
Array
(
[arg] => value
[val] => php
[cat] => technology
)