Page 1 of 1
why use ?show=page
Posted: Tue Dec 05, 2006 11:55 am
by tarja311
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
Posted: Tue Dec 05, 2006 11:59 am
by ok
?show=login is used if you handle many things in one PHP file.
For example:
Code: Select all
<?php
switch($_GET['show'])
{
case "login":
//Login stuff...
break;
case "register":
//Register stuff...
break;
default:
//Index (default) stuff...
}
?>
Posted: Tue Dec 05, 2006 12:01 pm
by aaronhall
It'san organization strategy that may make it easier to separate your presentation from application logic, like such:
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');
?>
as opposed to including the header and footer files in every file.
Posted: Tue Dec 05, 2006 12:02 pm
by feyd
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.
Posted: Tue Dec 05, 2006 12:08 pm
by MrPotatoes
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
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

Posted: Tue Dec 05, 2006 12:09 pm
by ok
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).
Posted: Tue Dec 05, 2006 12:12 pm
by tarja311
Thanks guys. Now i understand the point of it all.

Posted: Tue Dec 05, 2006 12:38 pm
by MrPotatoes
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

But, if you use OOP, you will probably want to use the letter (?show=login).[/quote]
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
Posted: Tue Dec 05, 2006 12:50 pm
by ok
The [ q u o t e ] tag disappeared from my post... weird. [/quote]