I think you’re missing what I’m saying about single quotes and about bloated nonsense like SMARTY… As it being faster is just part of it.
Single quotes:
Advantages:
Clearer code
White space neutral/white space preserving
much smaller/cleaner code than constantly doing <?php ?>
Fastest execution
Disadvantages:
must escape single quotes
Double quotes:
Advantages
Can inline a variable with less effort
Disadvantages
No white space preservation
Inherently slower since it needs to do more compares inside the loop.
Must escape double quotes, most people just make ugly markup by outputting singles instead
Smarty
Advantages
Even smaller code size
Disadvantages
Vague code through use of logic abbreviations
Vague code through cryptic abbreviations and changing standard functionality of common functions.
Significantly slower since it uses a pre-processor sitting atop PHP.
Requires installation of preprocessor that may not be available on all hosts. Said preprocessor adds overhead completely offsetting any code-size advantage.
I mean seriously, this:
<?php if(!empty($foo)): ?>
<?php foreach($foo as $bar): ?>
<a href="<?=$bar['zig']?>"><?=$bar['zag']?></a>
<a href="<?=$bar['zig2']?>"><?=$bar['zag2']?></a>
<a href="<?=$bar['zig3']?>"><?=$bar['zag3']?></a>
<?php endforeach; ?>
<?php else: ?>
There were no rows found.
<?php endif; ?>
Is an illegible train-wreck of badly written code. THIS:
if (!empty($foo)) {
foreach($foo as $bar) {
echo '
<a href="',$bar['zig'],'">',$bar['zag'],'</a>
<a href="',$bar['zig2'],'">',$bar['zag2'],'</a>
<a href="',$bar['zig3'],'">',$bar['zag3'],'</a>';
}
} else echo '
There were no rows found.';
Is clean, simple, clear – without resorting to installing some goofy preprocessor to sit on top of PHP adding just another unnecessary layer of abstraction. (seriously, whenever I see code like that first one I have the overwhelming urge to backhand someone)
Of course, I hate jquery on the same grounds. Probably stems from my not being particularly wild about C syntax languages and their needlessly complex and ridiculously vague and cryptic syntax. After thirty years of programming I don’t much doubt that C and Unix are a hoax… I’d rather hand assemble z80 or 8088 machine language than deal with C dialect languages – it’s SIMPLER.
In fact, if it wasn’t for the white space neutrality of single quotes, ease of interfacing to SQL databases compared to other languages, and robust in-built string handling I wouldn’t be using PHP in the first place.
The first of those being why I don’t understand why people even BOTHER with the “five hundred instances of <?php ?> for nothing” or the use of double quotes… it is NOT a good coding practice taking something simple and making it needlessly complex.
… but as a worshiper at the throne of Wirth, what do you expect from me?
Or as Micheal Abrash once said “Good coding practices make optimizations redundant”. IMHO the “don’t overoptimize” on things that are just sloppy/half-assed coding is a cop-out by the inept and the ignorant… especially when it’s no more or less code to simply say “use single quotes instead of doubles” – that’s NOT overoptimizing or overthinking, that’s good practice that if done from the start gives clearer code, marginally faster code, easier to maintain code, etc, etc… Overoptimizing is nonsense like white-space stripping – which usually just seems to be used by people who can’t code worth a damned in the first place!
Which should probably be filed alongside the other lame_excuses_for_not_being_a_web_professional