Best practice for lining up PHP syntax in HTML page I'm using Codeigniter but this goes for any project in PHP. Let's say I have the following code in my view. I've been struggling, trying to figure out how best to indent and display PHP code within standard HTML code.

...
...
&lt;div id="subcontent"&gt;
    &lt;?php
        if ($this-&gt;session-&gt;flashdata('message')) {
            ...
            ...
    ?&gt;
        &lt;div class="blah blah"&gt;
            ...
            ...
        &lt;/div&gt;
    &lt;?php 
        } 
    ?&gt;
&lt;/div&gt;


So notice how I nested HTML within the PHP code by escaping w/ the PHP syntax. This can get out of hand if you have lines and lines of code. I'm using Komodo and I've enabled "Indentation Guidelines" but even with that, most of my code doesn't line up. So my question is, how best to handle this?

I've actually resorted to keeping the PHP marker &lt;?php ?&gt; to the far left and not indenting them. Seems to work so far ...
You can use other kind of syntax:

...
...
&lt;div id="subcontent"&gt;
    &lt;?php if ($this-&gt;session-&gt;flashdata('message')): ?&gt;
        &lt;div class="blah blah"&gt;
            ...
        ...
        &lt;/div&gt;
    &lt;?php endif; ?&gt;
&lt;/div&gt;


So, &lt;?php ?&gt; can be in 1 line and I think it's beauty:)

Anyway, There are no any 'right' way to do it. You can(and should) choose your own one