Posted by NC on 01/12/06 03:09
Domestos wrote:
>
> I was wondering if there is a standard when mixing PHP and
> HTML script on a page...
No. There are only recommendations, such as sepration of logic from
presentation...
> 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
This is simply not going to work. If you save the file as *.html, PHP
code will not be executed.
> 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
Doesn't matter much... Your first example would probably work slightly
faster than the second one (if you save the file as *.php, of course).
But it will be one of those hard-to-tell differences...
Moreover, you example set is far from exhaustive. Consider this:
<?php
echo <<<EOHTML
<html>
<head>
<title>title text</title>
</head>
<body>
You name is $name
</body>
</html>
EOHTML;
?>
Cheers,
NC
[Back to original message]
|