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:
PHP is too messy/sloppy/crappy, because you have a tangled web of presentation and logic.
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.
Which of these is the best practice? Or is there an even better way that I'm not aware of?
<?php
if(!function()) {
echo '<div id="results">The result is a lie.</div>';
}
?>
Or
<div id="results">
<?php
if(!function()) {
echo 'The result is a lie.';
}
?>
</div>
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.