Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialTristan Nederhoff
Courses Plus Student 2,221 PointsShould i create many files wich include a header and footer, or should i create a array in index.php for including?
There are two options i guess? Build every page (products.php and contact.php for example) who all have included headers and footers.
I read somewhere that it is possible to use an array with a switch and _GET[$page] option to open other pages into the index.php. This means that my contact.php does not need a header.php and a footer.php because it it gets included in my index.php, wich already has a header and footer included?
(Sorry for my terrible English, i hope you understand my question a little bit)
1 Answer
Casey Ydenberg
15,622 PointsIn template speak you're basically describing the difference between "includes" and "extensions". All things considered, extensions are superior becuase the code is more DRY. But really, there's nothing wrong with includes: Randy uses them a lot in his courses, heavily utilized frameworks (ahem, wordpress) don't really allow extensions, and they can be complex if you aren't using a framework at all. Do it whatever way makes the most sense for your project.