Ok, I have been told on multiple occasions that something like:
<?php if($something == $this) : ?>
<h1>Something</h1>
<?php endif; ?>
<h1>Something</h1>
<?php endif; ?>
is far superior to something like:
<?php
if($something == $this)
echo "<h1>Something</h1>";
?>
if($something == $this)
echo "<h1>Something</h1>";
?>
Is this true? If so why? Performance? Speed? Code Organization?
04/24/2009 - 10:27
This is more of a concern when dealing with the presentation layer. Most of the time, the presentation layer should just be thought of as an HTML document and should include, when at all possible, plain old HTML.
The bottom example is the opposite of this. It's a PHP script that's generating HTML.
04/24/2009 - 10:55
Ah, good point Red man.
04/24/2009 - 13:57
I have to agree with you here. It is really a different feeling from the first snippet to the second.
Add Comment
[language] [/language]
Examples:
[javascript] [/javascript]
[actionscript] [/actionscript]
[csharp] [/csharp]
See here for supported languages.
Javascript must be enabled to submit anonymous comments - or you can login.