ohdang888 Posted May 26, 2008 Share Posted May 26, 2008 i know how to get the variable in the URL such as index.php?show_all=true but how woudl i get it if i just want to put "index.php?show_all"????... want to see if "show_all" exists in the url thanks! Quote Link to comment https://forums.phpfreaks.com/topic/107256-solved-getvar-in-the-url/ Share on other sites More sharing options...
.josh Posted May 26, 2008 Share Posted May 26, 2008 all the vars past through the url are stored in the $_GET array. Quote Link to comment https://forums.phpfreaks.com/topic/107256-solved-getvar-in-the-url/#findComment-549952 Share on other sites More sharing options...
ohdang888 Posted May 26, 2008 Author Share Posted May 26, 2008 so what would i do... $_GET['show_all'] ??? cause there is no definng what show all is, its just simple "show all" Quote Link to comment https://forums.phpfreaks.com/topic/107256-solved-getvar-in-the-url/#findComment-549955 Share on other sites More sharing options...
.josh Posted May 26, 2008 Share Posted May 26, 2008 ..is "show_all" a specific variable, or are you wanting to "show all" as in find out what all your variables are? if it's a specific variable, you'd access it by echo $_GET['show_all']; // this echo's the value of the variable if you are wanting to find out what variables are being passed in your url, $_GET is an array of those variables you'd access them any number of ways here's an example of how to echo them: foreach ($_GET as $key => $val) { echo $key . " = " . $val . "<br>"; } If neither of these is what you mean, then please clarify some more. Quote Link to comment https://forums.phpfreaks.com/topic/107256-solved-getvar-in-the-url/#findComment-549958 Share on other sites More sharing options...
DarkWater Posted May 26, 2008 Share Posted May 26, 2008 He means index.php?show_all, not index.php?show_all=true. Unless a parameter has a value in a URL, it doesn't get a spot in $_GET. echo $_SERVER['QUERY_STRING']; //would echo show_all if it was index.php?show_all Quote Link to comment https://forums.phpfreaks.com/topic/107256-solved-getvar-in-the-url/#findComment-549967 Share on other sites More sharing options...
ohdang888 Posted May 26, 2008 Author Share Posted May 26, 2008 ya thats it... thanks. Quote Link to comment https://forums.phpfreaks.com/topic/107256-solved-getvar-in-the-url/#findComment-549968 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.