why use ?show=page
Moderator: General Moderators
why use ?show=page
Hi all,
I have searched but have yet to find why programmers use this method to navigate around their websites. I've found that some do not use this, instead, in the url it says something like: site.com/login.php while others say something like: site.com/?show=login
Can anyone explain why this is used and the benefits of doing this?
thanks
--tarja
I have searched but have yet to find why programmers use this method to navigate around their websites. I've found that some do not use this, instead, in the url it says something like: site.com/login.php while others say something like: site.com/?show=login
Can anyone explain why this is used and the benefits of doing this?
thanks
--tarja
?show=login is used if you handle many things in one PHP file.
For example:
For example:
Code: Select all
<?php
switch($_GET['show'])
{
case "login":
//Login stuff...
break;
case "register":
//Register stuff...
break;
default:
//Index (default) stuff...
}
?>
- aaronhall
- DevNet Resident
- Posts: 1040
- Joined: Tue Aug 13, 2002 5:10 pm
- Location: Back in Phoenix, missing the microbrews
- Contact:
It'san organization strategy that may make it easier to separate your presentation from application logic, like such:
as opposed to including the header and footer files in every file.
Code: Select all
<?php
// index.php
include('header.php');
switch($_GET['show']) {
case 'signup':
include('signup.php');
break;
case 'login':
include('login.php');
break;
case 'index':
default:
include('index_page.php');
break;
}
include('footer.php');
?>- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Typically the latter is used in MVC (Model View Controller) back-end designs. There is often a single actual entry point to the application where the user interacts with most things through. The former can be all sorts of things. MVC can be simpler to maintain in the end due to a single point where you need to alter many things at once.
Some swear by MVC, some don't.
Some swear by MVC, some don't.
- MrPotatoes
- Forum Regular
- Posts: 617
- Joined: Wed May 24, 2006 6:42 am
what he said.feyd wrote:Typically the latter is used in MVC (Model View Controller) back-end designs. There is often a single actual entry point to the application where the user interacts with most things through. The former can be all sorts of things. MVC can be simpler to maintain in the end due to a single point where you need to alter many things at once
it makes it eaiser to maintain in coding style if anything. i don't like the latter for a multitude of reasons. for one the include structure becomes convuluted i've found out. it's a pain int he ass unless you use the file as the root. secondly when you need multiple files it gets cumbersome. i still prefer pretty URL's though
what he said.
it makes it eaiser to maintain in coding style if anything. i don't like the latter for a multitude of reasons. for one the include structure becomes convuluted i've found out. it's a pain int he ass unless you use the file as the root. secondly when you need multiple files it gets cumbersome. i still prefer pretty URL's though
[/quote]
But, if you use OOP, you will probably want to use the letter (?show=login).
it makes it eaiser to maintain in coding style if anything. i don't like the latter for a multitude of reasons. for one the include structure becomes convuluted i've found out. it's a pain int he ass unless you use the file as the root. secondly when you need multiple files it gets cumbersome. i still prefer pretty URL's though
But, if you use OOP, you will probably want to use the letter (?show=login).
- MrPotatoes
- Forum Regular
- Posts: 617
- Joined: Wed May 24, 2006 6:42 am
But, if you use OOP, you will probably want to use the letter (?show=login).[/quote]ok wrote:what he said.
it makes it eaiser to maintain in coding style if anything. i don't like the latter for a multitude of reasons. for one the include structure becomes convuluted i've found out. it's a pain int he ass unless you use the file as the root. secondly when you need multiple files it gets cumbersome. i still prefer pretty URL's though
did i not just say that? lol, i was agreeing with feyd. also, you don't need to use OOP in order to use the query string. you don't need to use OOP to use the onsingle entry point pattern either