You are here: Re: Article on mixing php and html « All PHP « IT news, forums, messages
Re: Article on mixing php and html

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация