Basically I was saying what Jeff just said.. tho I skipped the alternative format. Shame on me! I got lost in trying to say that you CAN HTML withn a PHP loop, you just need to take care to keep your code readable. Gains in readability far outweigh ALMOST any speed gain of dropping in and out of PHP. So I FAVOUR dropping in and out for the reason John listed AND the additional reason that dropping out of PHP preserves your HTML formatting easily ( indents, new lines etc) ...
I really should have written this as well to keep my example consistent.
I just added two asides tho.
<?php for($i2=1,$th=array('st','nd,'rd','th'); $i2<=15; $i2++) : ?>
<li>I am the<?php echo $i2, (($i2)<3)? $th[$i2-1]:$th );?> list item<li>
<?php endfor ?>
1) Use common sense, For small scripts or simple templates it makes little difference. I want to keep my samples sort so the scripts/ mock templates are short and basic. It may not always be the smart thing to do.
This is NOT clever at all:
2) you gain a small speed boost using singe quote for non parsed text, also you can eco with "," instead of "." : eg.: echo 'I am static text ',$bar, 'I was joined with a comma instead of a dot because its faster than concatonating with a period'," variable $a and newlines need tobe parsed \n";
<?php while($hasNextP()) : ?>
<?php endwhile ?>