|
Posted by Erwin Moller on 07/05/06 11:13
Dodger wrote:
> Okay, background... yes, I am another of those evil, spurned, damnable
> Perl mongers, but I'm not trying to start a flamewar, I'm juust tryung
> to understand something...
Hi Dodger,
Other helped you with the msql part, but I want to make 1 remark on your
next comment:
>
> I can write a script in Perl like so, and it's pretty to me (and the
> using of the heredocs I think does defend perl against many arguments
> withthe HTML being all escaped and explicit returns and stuff -- which
> I can see... 'print "<p class=\"text\">stuff</p>\n";' is terrible to
> me to.. so I use heredocs), and simple, and fast under mod_perl...
>
Only people who like to write unreadable code use syntax like that.
consider:
print "<p class=\"text\">stuff</p>\n";
and
<p class="text">stuff</p>
The latter is the usual normal way if you first jump out of the PHP-tags,
which every experienced PHP-coder with a sane mind does, for sake of
readability.
If you need to jump back to get some variable, do this:
[just an example that uses ADODB-lib.]
<table>
<tr>
<td>
userid
</td>
<td>
firstname
</td>
<td>
lastname
</td>
</tr>
<?php
$SQL = "SELECT userid, firstname, lastname FROM tbluser;";
$RS = $con->Execute($SQL)->getArray;
for($i=0;$i<count($RS);$i++){
$row = $RS[$i];
?>
<tr>
<td>
<?php= $row["userid"] ?>
</td>
<td>
<?php= $row["firstname"] ?>
</td>
<td>
<?php= $row["lastname"] ?>
</td>
</tr>
<?php
}
?>
</table>
I think that makes great readable code, both from a HTML perspective as from
a PHP perspective.
Don't use print and echo for HTML, unless you have some compelling reason.
just my 2 cent.
Regards,
Erwin Moller
Navigation:
[Reply to this message]
|