If statements vs. other options - displaying pages

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
kaYak
Forum Commoner
Posts: 65
Joined: Mon Feb 02, 2004 2:43 pm
Location: USA

If statements vs. other options - displaying pages

Post by kaYak »

Hello,

I'm not sure how I should set this up. I have a section of my site that needs to be able to support high traffic loads so I want the best bandwidth setup I can get. I'm not sure how I should display the pages. Right now I have one file with about 1,500 lines of code. It is all if statements to display the pages. I think it may be better to split these up into multiple files and then make an include file containing the functions everything shares. I also thought of using a switch in one file that includes each individual page and processing when needed. Can someone provide the pros and cons of these to better help me decide what options I have and which to go with. Thanks in advance.
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

This is what's known as a FrontController.

A FrontController has to identify the request type and then map this to something which can handle it - see the section on Dynamic Invocation in the above article for an alternative to interminable if/else's or switch/cases.
Post Reply