Out of curiosity, I just want to ask about a good coding practice. The below code have the same outputs but have difference coding practice.
So, which is better?
This one:
<?php foreach ($cart as $item): ?>
<tr>
<td><?php echo $item['name']; ?></td>
<td><?php echo $item['checkin']; ?></td>
<td><?php echo $item['checkout']; ?></td>
</tr>
<?php endforeach; ?>
Or this one:
<?php
foreach ($cart as $item):
echo "<tr>";
echo "<td>$item['name']</td>";
echo "<td>$item['checkin']</td>";
echo "<td>$item['checkout']</td>";
echo "</tr>";
endforeach;
?>
It depends where and what kind of script you are using.Above from those two samples I will choose the first one.Because if you will go through the code you can see proper indentation with spaces are maintained there.It helps to debug the code.If you are asking about HTML codes then first work is to check whether the code is valid or not.Because code validation makes ease to debug. Here are some of the links, just go through them.Hopefully you will get some to make your code more good
PHP Coding style – Best practices
http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/
http://www.ibm.com/developerworks/opensource/library/os-php-5goodhabits/index.html
http://framework.zend.com/manual/en/coding-standard.coding-style.html