Please Stop Echoing Things

For my little brother who likes to embedding PHP to html but not sure how to do it nicely.

You probably have ever seen or even written code like below:

<table>
<?php
foreach($results as $row) {
echo '<tr>';
echo '<td>'.$row->name.'<td>';
echo '<td>'.$row->email.'</td>';
echo '</tr>';
}
?>
</table
  1. PHP short echo tag (<?=) is now available forever (PHP version 5.4+)
  2. PHP have alternative syntax of control structure: http://php.net/manual/en/control-structures.alternative-syntax.php

With those powerful feature, we can rewrite code above little bit more handsome:

<table>
<?php foreach($results as $row): ?>
<tr>
<td><?= $row->name; ?></td>
<td><?= $row->email; ?></td>
</tr>
<?php endforeach; ?>
</table>

See ? so what do you think ?