Assuming a URL of www.domain.org?x=1&y=2&z=3
, what would be a smart method to separate out the query elements of a URL in PHP without using GET or REQUEST?
$url = parse_url($url);
echo $url[fragment];
I don't think it's possible to return query parts separately, is it? From what I can tell, the query will just say x=1&y=2&z=3
, but please let me know if I am wrong. Otherwise, what would you do to parse the $url[query]
?
Fragment should be Query instead. Sorry for the confusion; I am learning!
$url[fragment]
means "get the value of the constantfragment
and use this to get the key from$url
". You probably means$url['fragment']
? Fragments are stuff after#
btw. If you're looking for the variables between?
and#
this is the "query".$_GET['x']
or are you parsing a URL separate from the one belonging to your script??
in the url is called the argument. Got that now. I already understood$_GET[]
but my thought is about processing the$url
and not using that function.query
orQuery
?