You should never, under any circumstance, be writing in your code more than once.

Use a header file. Call it what you want, I like ‘header.php’ or ‘header.inc.php’ and have it handle all those things.

Your code should look something like this:

<?php

// Author
// Test URL
$page_title = "Ad Edit";
$useCKeditor = true;
include 'header.php';

$command = $_REQUEST['command'];

if($command=='something) {
...

You should also never be writing more than once. That should be in a footer file. Continuing the above example:


if($command=='something_else') {
...
}

include 'footer.php';
?>

In your header you should include your common file as well as any files necessary for view-based pages. You should also have boolean options for disabling navigation and other items that aren’t necessary when performing ajax calls so you can continue to use your header for those fun things. Your footer should also have an option to not display itself (preferably inheriting the same variable as the header) and in general shouldn’t be trying to do too much.

August 20th, 2013

Posted In: Basics

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: