RE: [PHP] mixing HTML and PHP code
| From: | MR | Date: | Fri, 12 Jan 2001 21:10:08 +0000 |
| Subject: | RE: [PHP] mixing HTML and PHP code | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-34297@lists.php.net to get a copy of this message | ||
Alex Black ...
> <input type="text" name="hello" size="20"
> value="<?=$value?>">
>
> is really not that much harder to write.
>
> html people can ignore it, php can find their code, and those that know both
> can reap the benefits.
>
> what about loops?
You mean that this code
<?
connect_to_database();
parse_query();
execute_query();
echo "<TABLE>";
while (fetch_row_from_query())
{
$output = data_from_fetched_row();
$more_output = more_data_from_fetched_row();
echo "<TR><TD> $output </TD><TD> $more_output
</TD></TR>";
}
echo "</TABLE>";
?>
would be better if it were written this way? :
<?
connect_to_database();
parse_query();
execute_query();
?>
<TABLE>
<? while (fetch_row_from_query()) : ?>
<? $output = data_from_fetched_row();
$more_output = more_data_from_fetched_row(); ?>
<TR><TD><?=$output?></TD><TD><?=$more_output?></TD></TR>
<? endwhile; ?>
</TABLE>
I _personally_ prefer the upper implementation, as all my web developing team (that is, only me :-)
know both PHP and HTML and don't
like the code to be *plagued* of <? ?> <? ?> <? ?> as in above example.