I am new to designing web pages using PHP so request the experts to advise me. In order to keep the index page simple I have used the "include" function for isolating all the info on my website. Please advise whether this is a good practice or not ?
Hello, I would advise you splitting up the Header and Footer file then just include it for simplicity. Then just: include("header.php"); and include("footer.php");. In my opinion that is the easiest way to do it. That is how i always do it.
if you are sure with your header part that will be common for all the pages then better split the design into header and footer
You definitely want to make use of include files whenever possible, even for simple things. They really do help when you have to make changes. I use different includes to separate the content on the page and then sprinkle in some functions that help place widgets or other smaller parts of my page. Here's a little tip that might help you if you didn't already know: The other (better) option is setting the PHP directory path on your webserver so it gets included automatically.
When it comes to include(), require() and code reuse in general the think to keep in mind is Don't Repeat Yourself or DRY. So keep it DRY. Never copy and past anything! if it can be put in a common included file. You'll save yourself sooo much time in the long run and future programmers who work on your site will thank you.