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
<?php include_once('header.php'); // my content include_once('footer.php'); ?>
<!doctype html> <html> // rest code