With Magento design files, there seems a very strong preference to using the alternative php syntax (example below). What are the technical advantages? or what is the technical appeal if it is only a style preference?
<div class="page-title title-buttons">
<h1><?php echo $this->__('Shopping Cart') ?></h1>
<?php if(!$this->hasError()): ?>
<ul class="checkout-types">
<?php foreach ($this->getMethods('top_methods') as $method): ?>
<?php if ($methodHtml = $this->getMethodHtml($method)): ?>
<li><?php echo $methodHtml; ?></li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
There is no “advantage” or “disadvantage”. It comes down to preference and maintainability.
REMEMBER => You should really be SEPARATING PHP and HTML syntax. Keep your PHP and your HTML in separate files – this is for maintainability and lots of other reasons (theres lots of info out there if you search). There is no way you can completely separate the two things… you’re always going to need to insert PHP variables into HTML and stuff, but this should be kept to a minimum.
Therefore I prefer to use that alternative syntax in template files in WordPress, Codeigniter and other things because the way I see it you’re inserting PHP into HTML in template files, so lets keep those PHP blocks insular.
i.e. to me:
and vice versa:
Again, there is no “technical advantage” its just cleaner and better (IMO). This is mixing PHP and HTML too much:
And this is just plain terrible: