Skip to main content
Participant
October 11, 2012
Answered

Putting header of page in separate php file

  • October 11, 2012
  • 1 reply
  • 690 views

I have read that it is good practice to put the header of page in separate php file, so that when the changes are done, they are done at one place and reflected throughout the site.

But including headers in separate file increases the download time of the page. What do you suggest in this case?

Also, is it fine that all the pages of a website bear .php extension. Are there any tradeoffs.

This topic has been closed for replies.
Correct answer David_Powers

yashi58 wrote:

But including headers in separate file increases the download time of the page.

No, it doesn't. The PHP engine adds the output of include files before sending the response to the browser. The only time using include files would increase the download time is if you have complex programming logic in the file, but the time taken to process that logic would be the same even if it were in the same file as the main page.

The only thing you need to be careful about when using include files is that Dreamweaver has difficulties if you put the doctype, <html>, <head>, and <body> tags in an include file.

Use the .php filename extension for all include files. Although it's not mandatory, it's more secure.

1 reply

David_Powers
David_PowersCorrect answer
Inspiring
October 11, 2012

yashi58 wrote:

But including headers in separate file increases the download time of the page.

No, it doesn't. The PHP engine adds the output of include files before sending the response to the browser. The only time using include files would increase the download time is if you have complex programming logic in the file, but the time taken to process that logic would be the same even if it were in the same file as the main page.

The only thing you need to be careful about when using include files is that Dreamweaver has difficulties if you put the doctype, <html>, <head>, and <body> tags in an include file.

Use the .php filename extension for all include files. Although it's not mandatory, it's more secure.

yashi58Author
Participant
October 12, 2012

Thanks David. That solves the issue.

I had this confusion because I checked the downloading time of the page that I designed i.e. career.html and career.php(header included in separate file) on tools.pingdom.com. For career.php page it showed 1.5 sec more to download than career.html page.