Friday, July 29, 2011

HTML and PHP includes

I know it's been a long time since I wrote here, but [replace with usual bla-bla], so let me make it up to you guys and give you a nice little hint here.

Usually when I want to build a website quickly and where design or dynamism is not all that important, I use simple HTML instead of PHP as I found it being much quicker to write. However, not being dynamic, a website built in HTML would be very complicated and time consuming to apply any changes to, unless you use a website builder software like Dreamweaver (not linking it, they make enough money already anyway :) and use templates. Thus, to simplify things, you may use includes, meaning you create a set of code, put it into a simple HTML page and then with a short line of code, you simply include it in your pages.

The code is fairly simple, it looks like this:
(click in the box to highlight the code for copy)

Note: it only worked for me using SHTML (simply rename your page to read [page_name].shtml instead of [page_name].html) although I have not seen this being stated in the article I took this information from. As usual, let me disclose my source, a nice article about this that actually also explains the way to handle includes using PHP: How Do I Include One HTML File in Another?

Hope you will find this useful! Look out for more articles from me, I have scheduled some now to keep up the wibe! ;)

No comments:

Post a comment

Dear legitimate commenters, please post your comments below. I'd be happy to receive your feedback; helps me a lot improving, or getting reassurance that I'm doing something really great here.

IMPORTANT! A note to commenters planning on advertising their business in comments: please be informed that I'm NOT going to post your comments but will ALWAYS mark them as SPAM.