How to not mix presentation with logic?
<p>I use PHP quite a bit, and whenever I see a "PHP-hate" thread on some forum or even popular PHP-related discussions here, I usually see something along the lines of:</p>

<blockquote>
  <p>PHP is too messy/sloppy/crappy, because you have a tangled web of presentation and logic.</p>
</blockquote>

<p>Then I see the PHP-Defenders replying to some version of the above saying that is isn't necessarily true. I got to thinking "How is this possible...?" and "What counts as mixing presentation with logic?" I couldn't figure it out, so now I'm here.</p>

<p>Which of these is the best practice? Or is there an even better way that I'm not aware of?</p>

<pre><code>&lt;?php
    if(!function()) {
        echo '&lt;div id="results"&gt;The result is a lie.&lt;/div&gt;';
        }
?&gt;
</code></pre>

<p>Or</p>

<pre><code>&lt;div id="results"&gt;
    &lt;?php
        if(!function()) {
            echo 'The result is a lie.';
            }
    ?&gt;
&lt;/div&gt;
</code></pre>

<p>I know the above examples don't really look like a big deal, but after browsing through web apps of mine, I realized it was all kind of messy (because I was mixing HTML and PHP), so I was hoping there was a good way to develop while keeping things nice and neat. </p>
