Page 1 of 1

OOP and Get statements

Posted: Tue Apr 20, 2010 1:27 am
by Goofan
Hi.
I wonder if its any good to state a code on Get statements and OOP?
Exampel:
I got my index.php
in it i got like if that do that statements which indicates if the get "action" = " ... " or " ... "
Then collect from OOP... I am building an internet game which is based on alot of scripting and pages.
Would this do something bad for my script or anything else?

//Thanks in advance
//Thomas

Re: OOP and Get statements

Posted: Tue Apr 20, 2010 4:53 pm
by Christopher
Some example code would make your question clearer. It sounds like you are using if() statements to check the values in $_GET?? That is one way to handle it. You should look at the Page Controller and Front Controller patterns.

Re: OOP and Get statements

Posted: Wed Apr 21, 2010 3:50 pm
by Goofan
Ok, so exampels:
If $_GET.... is action page then
include oop
end if...


Now im asking if its ok to go forth with this all the way through a projekt so its basicly only one page and alot of OOP pages..

Im building a game BTW just so u know the size of the projekt "ITS HUGE"

Re: OOP and Get statements

Posted: Thu Apr 22, 2010 2:43 am
by Christopher
What you are describing is a Front Controller. Yes it is a good idea.

Perhaps you should consider using a framework like Zend or CodeIgniter.

Re: OOP and Get statements

Posted: Thu Apr 22, 2010 3:33 am
by Chris Corbyn
Definitely look at some frameworks. If your project is going to be quite large then using a documented framework with some good conventions will make things easier in the long run.

But at the very least, do some reading up on the front-controller design pattern as Christopher mentions. You will find many examples offering approaches with differing levels of complexity.