0

I am making a CMS software, and I need php to generate some pages, I would like for most of the content on the pages to be the same, so I was wondering was it possible to link the body tag to a default html page. For example to have a html page with <body> <h1> Hello </h1> </body> and for all the pages that php generate to have that content. I did some searching and found only one question like this but it did not have a very detailed answer, and I tried creating a html page(for example called page.html) with something like <body> <h1> Hello </h1> </body> and make php generate a body using <body src="page.html"></body but with no luck.

Thanks in advanced

1 Answers1

0

Remember you can include files in PHP, so you can include and push html files piece by piece.

For example,

header.html :
<html><body><h1>hello</h1>

footer.html
</body></html>

In your PHP, you can do something like this :

include header.html
include UNIQUE_PAGE_CONTENT_HERE
include footer.html

Many MVC frameworks allow you to do this very easily

Patrick
  • 3,289
  • 2
  • 18
  • 31
  • How would I do this when writing to a file –  May 29 '14 at 16:41
  • Why would you need writing to file in a CMS? you would store most of your code in the database itself i reckon, You don't need to make a .html file for every page, these should all be made dynamically – Patrick May 29 '14 at 16:45
  • Ok How would I accomplice this I tried just putting this in a php file but i just got a white screen –  May 29 '14 at 16:47
  • See if this helps : http://stackoverflow.com/questions/9539849/how-to-echo-the-whole-content-of-an-html-file-in-php – Patrick May 29 '14 at 16:50