Posted by Dasdan on 01/12/06 02:38
> 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
the easiest way is to save all your files with extension .php
code not surrounded by <?php ?> will not be parsed by the php engine.
so for your example
<html>
<head>
<title>title text</title>
</head>
<body>
Your name is <?php print $name; ?>
You firstname is <?php print $firstname; ?>
</body>
</html>
save as php
you could also save as .html (not recomended), but in that case you
have to change your apache webser to handle the .html file as php
AddType application/x-httpd-php .html
Kind regards,
Kevin Wood
--
http://www.dasdan.be
[Back to original message]
|