Creating full PHP files for every page.
I have a folder structure like this:
Code: Select all
/includes
/head.php
/menu.php
photo.php
userprofile.php
index.phpCode: Select all
<html>
<head><?php include 'includes/head.php' ?></head>
<body>
<?include 'includes/menu.php' ?>
Page contents.
</body>
</html>One full page, included contents.
I have a folder structure like this:
Code: Select all
/pages
/photo.php
/userprofile.php
index.phpCode: Select all
<html>
<head>Title, meta, CSS...</head>
<body>
<div id="menu">The common menu</div>
<?php include "pages/$page.php"; ?>
</body>
</html>So, if I want a user page the URL is: example.com/index.php?p=userprofile&user=123
I know there are lots of things that can affect my two scenarios (URL rewriting, templating, etc), but I think the problem can always be traced back to these simple examples.
I think each method has got pros and cons (CSS and JS inclusion, code maintenance, etc).
What do you think? Which do you use?