Maintain (X)HTML Indentation - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Maintain (X)HTML Indentation (/showthread.php?tid=15610) |
Maintain (X)HTML Indentation - El Forum - 02-10-2009 [eluser]underskor[/eluser] How do you stop PHP reverting the indent level? For example: Code: <?php Code: [..] Code: [..] Hoping there's a way to do this which doesn't involve mutilating my nicely indented/formatted PHP. Maintain (X)HTML Indentation - El Forum - 02-10-2009 [eluser]thinkigniter[/eluser] try Code: <body> Maintain (X)HTML Indentation - El Forum - 02-10-2009 [eluser]underskor[/eluser] That works great, except it counts as "mutilating my nicely indented/formatted PHP". I was hoping there would be some kind of solution which doesn't require me to add tab characters before each output, because I have to manually do so. I don't understand why it does that. The first echo indents at the correct level, but the following echo's do not? Maintain (X)HTML Indentation - El Forum - 02-10-2009 [eluser]TheFuzzy0ne[/eluser] I would have thought something like this would work: Code: <body> I think that the blank lines are necessary to stop the variables being appended to a single line. Or, you could incorporate some kind of loop like this: Code: <body> Again, if memory serves correctly, you need the empty line to prevent the variables being appended to the same line. It just takes a bit of trial and error, and a bit of practice, and then you will start to learn what needs to be done. Hope this helps. Maintain (X)HTML Indentation - El Forum - 02-10-2009 [eluser]TheFuzzy0ne[/eluser] [quote author="underskor" date="1234272703"]I don't understand why it does that. The first echo indents at the correct level, but the following echo's do not?[/quote] Simple. The PHP parser doesn't care about spaces and tabs, (as long as there's at least one where needed of course) PHP simply outputs what's in the quotes, not what's outside them. Code: <?php echo "this line is not indented when printed out"; ?> The only outputting PHP does, is what's between the quotes, not what's outside of them. Any padding needs to be added a) inside the string quotes, or b) outside of the <?php ?> tags. Hope this helps. Maintain (X)HTML Indentation - El Forum - 02-10-2009 [eluser]underskor[/eluser] I see, thanks Fuzz. Did some testing and it seems that the blank line doesn't matter, it's just the seperate blocks of PHP. eg. Code: <?=$variable; ?> Thanks for your replies everyone. |