Page layout pattern for PHP pages

I know a bit about PHP, but never studied in depth, but now I will develop some real sites.

One doubt I have is about writing the common HTML elements like Doctype, head and fixed layout like menus or top. I always created a class called Layout to write these parts of the page, and so, in every page, I call the methods of Layout class to build the layout ans basic HTMl elements.

My question is if there is another way to do this without the need of call the Layout methods in every page, or maybe, no need for a Layout class. Something like a pattern file with the basic HTML for every page or something like that.

So, something like this exists or is needed to put calls in my code to generate the basic HTML content?


Why you're not using template engines? Twig or Smarty. In other case if you don't want to use template engines, you can make document e.g. posts.php and include header.php which contains header data of html


// my content


<!doctype html>
// rest code

Need Your Help

How to separate configurations in ASP.NET? deployment

My team is doing web development (ASP.NET, WCF), and we are at a beginning stage where everyone needs to make DB changes and use own sample data.

Telling Weka Which Attributes to Predict in ARFF File?

machine-learning data-mining weka arff

I'm trying to get Weka to predict from the command line, but I'm concerned I might be doing this wrong. I read the Data Mining book and searched their site for documentation, yet what I found was v...