johnsmith153 Posted July 8, 2010 Share Posted July 8, 2010 I want to setup a website and structure a template to prevent page/code duplication. I suppose I could do a simple system: <?php //index.php include('everything.php'); include "htmlHeader.php";//would include HTML doctype and head tags + opening <body> $page = $_GET['page']; include "pages/".$page.".php"; include "htmlFooter.php"; ?> How would I change this template so I could add extra PHP / JavaScript includes to certain pages only (e.g. a function to access a database would be in the everything.php file, but a one-off PHP function wouldn't be). All pages/pagename.php are loaded after HTML output. Or do I need 3 page includes: 1. before HTML output for one-off PHP 2. In the <head> tag for one-off JavaScript 3. the one just like above in the <body> Quote Link to comment Share on other sites More sharing options...
Alex Posted July 8, 2010 Share Posted July 8, 2010 Just by including or echoing something that output isn't sent to the browser. In the script you provided there would only be 1 output to the browser (at the end of execution) as is the case in most situations unless you're using output buffering. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.