jwk811 Posted May 7, 2011 Share Posted May 7, 2011 i know theres a way but i just forget. i want to do a switch function. switch ($_GET['page']) { case 0: include 'page'; break; case 1: include 'page1'; break; case 2: include 'page2'; break; default: include 'page'; } ?> just like that but if there is no $_GET page i just want it to do the default. instead of doing if isset GET page do switch else default page. i just want it to be simpler by doing something like switch(isset$_GET etc. Link to comment https://forums.phpfreaks.com/topic/235792-php-switch-if-isset/ Share on other sites More sharing options...
Zurev Posted May 7, 2011 Share Posted May 7, 2011 Why not just throw this at the top: $_GET["page"] = (isset($_GET["page"])) ? $_GET["page"] : "default"; That way it should just default to default unless you specified a case default. So you're pretty much setting $_GET["page"] if it isn't already. Link to comment https://forums.phpfreaks.com/topic/235792-php-switch-if-isset/#findComment-1212021 Share on other sites More sharing options...
jwk811 Posted May 7, 2011 Author Share Posted May 7, 2011 yes that was what i was looking for lol thank you Link to comment https://forums.phpfreaks.com/topic/235792-php-switch-if-isset/#findComment-1212032 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.