FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Embedding HTML Within a PHP Statement
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Embedding HTML Within a PHP Statement [message #176004 is a reply to message #175991] Mon, 14 November 2011 19:54 Go to previous messageGo to previous message
houghi is currently offline  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
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Smart File Downloader - simple script on xampp
Next Topic: Prevent unlink(...) warning
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 21:01:49 GMT 2024

Total time taken to generate the page: 0.03856 seconds