Coming from REAL programming languages, the notion of a script flat outputting content outside of a tag-style element always struck me as silly, wasteful, and potentially insecure…
Which is why as a rule of thumb I only use one <?php ?> pairing per FILE.
… as in the ENTIRE file.
To me, opening and closing <?php ?> over and over and over again just seems wasteful, nonsensical, confusing, impossible to maintain once any sort of logic flow is in there, and is a horribly piss-poor way to code a site.
YMMV… though also, echo is faster than opening and closing PHP – EVEN FASTER if you send it as separate parameters using commas instead of making php do a massive string addition before sending to echo with periods. It’s only 1-2%, but when it’s 1-2% using the same number of characters, that’s just good coding practice.
… and less code…
<?php
// open should be first thing in file!
$myVar1=‘abc’;
$myVar2=‘edf’;
echo ‘myVar1 is ‘,$myVar1,’ and myVar2 is ‘,$myVar2,’.’;
// close should be last thing in file
?>
with no other <?php and ?> ANYWHERE in the file. If you’re going to use a programming language, USE IT AS A PROGRAMMING LANGUAGE.
But to put that in perspective, I’m the guy who considers using double quotes in PHP to be just as idiotic. Moronic… Herpa-freaking-derp…