|
Posted by Wenting, Marcel on 05/18/06 09:01
Domestos wrote:
> Hi all,
>
> I am currently writing pages that are pure PHP. i.e. they begin with the
> <?php symbol.
>
> I am embedding all the HTML within echo ' ' commands even the <HTML> <HEAD>
> and <BODY> tags
>
> i..e.
>
> <?php
> echo '<HTML><HEAD><TITLE>Title</TITLE></HEAD><BODY></BODY></HTML>';
> ?>
>
> Is this the right way to do things? or should I be embedding PHP into the
> HTML page?
>
What is the right way?
You dont echo a doctype, so you example isnt right ;-)
You example isn't wrong, but will be completely parsed by PHP.
This will consume more cpu power than when using HTML outside the php tags
I always prefer to keep html and php seperated as much as possible,
like:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Whatever</TITLE>
</HEAD>
<BODY>
<TABLE>
<?
for ($i=1; $i<100;$i++){
?>
<TR>
<TD><?=$i; ?></TD>
</TR>
<?
}
?>
</TABLE>
</BODY>
</HTML>
This keeps my code clean & fast, but it also just my way of working
Navigation:
[Reply to this message]
|