|
Posted by d on 01/12/06 12:34
"Domestos" <never.you@mind.com> wrote in message
news:u7hxf.20$77.4@newsfe3-win.ntli.net...
> Hi all,
>
> I was wondering if there is a standard when mixing PHP and HTML script on
> a
> page... and if there were any articles on this subject...
>
> i.e. do I make every page a .php page on my website and echo html when I
> need to or...
>
> should I make every page html and embed php when I need to..
>
> Obviously this only applies to pages where a mixture of php and html is
> required...
>
> for example... which is better or more standard....
>
> <html>
> <head>
> <title>title text</title>
> </head>
> <body>
> You name is <?php $name?>
> </body>
> </html>
>
> saved as index.html
>
> or
>
>
> <?php
> echo '<html>';
> echo '<head>';
> echo '<title>title text</title>';
> echo '</head>';
> echo '<body>';
> echo 'Your name is '.$name;
> echo '</body>';
> echo '</html>';
> ?>
>
> saved as index.php
>
> TIA
> Andy Mak
Ideally speaking, any file that spits out html should have an .html
extension, as when the client sees it, it's HTML (regardless of how it was
created). As others have pointed out, that will require a minor change in
your server's configuration, but yields more professional results.
Personally, I use a templating toolkit (I wrote my own), which handily
seperates HTML from PHP entirely. Having them both in the same file is
terrible from a production standpoint.
[Back to original message]
|