Re: Embedding HTML Within a PHP Statement [message #176004 is a reply to message #175991] |
Mon, 14 November 2011 19:54 |
houghi
Messages: 45 Registered: September 2011
Karma:
|
Member |
|
|
Balazs Nadasdi wrote:
> more readable (i don't like this: <?php } ?>):
>
> <table>
> <tbody>
> <?php foreach ($someDBResult as $oneRow): ?>
> <tr>
> <td>
> <?=$oneRow["firstName"]; ?>
> </td>
> <td>
> <?=$oneRow["initials"]; ?>
> </td>
> </tr>
> <?php endforeach; ?>
> </tbody>
> </table>
I would use something like:
<?php
echo "<table><tbody>";
foreach ($someDBResult as $oneRow);
echo "<tr><td>".$oneRow["firstName"]."</td>
<td>".$oneRow["initials"]."</td>
</tr>";
endforeach;
echo "</tbody></table>";
?>
The reason I do it this way is that for me it is less confusing as it
looks more like 'standard' HTML and is _for me_ easier to read after
several months.
Is there an advantage or disadvantage of using echo instead of print?
houghi
--
> This is written under the influence of tv channel
> BBC Two (as there was nothing else on).
> I am now watching : Great British Food Revival
|
|
|