Click to See Complete Forum and Search --> : Single Index vs. Separate Files


mikepurvis
08-26-2004, 10:14 PM
phpMyAdmin, phpBB and vBulletin all have separate files for each action. (showthread, viewforum, etc...)

But I've seen some sites that have one single index.php file so that every uri looks like www.mydomain.com/?action=xx

Does doing it this way put more strain on the parser? Is there a better or worse way, or is it just preference?

The reason I ask is that in both of the 'forum' situations, the pages are made to be identical by having an included header.inc and footer.inc. But in a situation where I've got a sidebar with a wrapper div and container div and whatever, it's less convenient for making consistent pages.

What's the correct course of action?

(the layout page is this: http://kitchencss.uwmike.com/)

MstrBob
08-26-2004, 11:16 PM
Well, they're probably just doing an index file, and the action paramater includes a file. Still multiple files for actions. It's easier that way.

And layout complexity shouldn't stop you from using includes. Simply put everything from your DTD to the HTML tag right before your content in one file, and everything after content in another. Usually I do something like:

header.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="Content-Style-Type" content="text/css" />
<link rel="stylesheet" type="text/css" href="stylesheet.css" />
<title>My Website.com</title>
</head>
<body>
<h1>My Header</h1>
<div id="content">
footer.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="Content-Style-Type" content="text/css" />
<link rel="stylesheet" type="text/css" href="stylesheet.css" />
<title>My Website.com</title>
</head>
<body>
<h1>My Header</h1>
<div id="content">

So my php pages look like:

<?PHP
// code here
include("header.php");
echo("outputted content.");
include("footer.php");
?>


And by doing it the method that the site you're talking about does put a bigger strain on the parser, but on the server, since the server now needs to include another file.