OOP and Get statements

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

OOP and Get statements

Post 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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: OOP and Get statements

Post 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.
(#10850)
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

Re: OOP and Get statements

Post 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"
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: OOP and Get statements

Post 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.
(#10850)
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: OOP and Get statements

Post 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.
Post Reply