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 trial
uworlds
1,784 PointsHow can I use a PHP include yet retain my indentation in the HTML?
Dear Treehousers,
I am using an include in PHP to reduce repetitive code across a test Web site, in other words:
<? include "../includes/header.h"; ?>
What is really bugging me is viewing the source code in a browser with Ctrl+U (Firefox) and the indentation is totally messed up.
I know it's pedantic; however, I get quite obsessed with properly aligned HTML.
Is there a way to make the include work so that it pastes the contents of the file exactly as the code exists in the include file? The tabs seems to be all over the place after being included but are perfectly aligned in the file (it looks a mess in the browser Ctrl+U).
Many thanks, Mike
1 Answer
thomascawthorn
22,986 PointsIndentation is what it is to make code more readable. Is it important the code in your source is readable? If not.. I wouldn't worry about it!
uworlds
1,784 Pointsuworlds
1,784 PointsHi Tom,
Perhaps that's the right approach, and just keep my own source code in my own files looking good & aligned, and then which ever way it gets compiled and displayed in browser source code I should forget about.
It seems like there are some options around like using a set:paste or something, but I'm really not sure I understand how you turn it on and maybe it's not relevant anyways.
Thanks again and take care, Michael