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 Rich on 01/12/06 19:33

In article <26hxf.19$77.2@newsfe3-win.ntli.net>, Domestos says...
>
>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
>

Hi Andy,

Your second example would probably be more of a headache than it's worth. You
can save your first example as index.php and only the "<?php...?> is parsed by
the server, so you don't need to use all the echo commands to print the plain
HTML.

One nice feature of PHP is you can mix the HTML and PHP code together, like you
did in your first example. May want to come up with a consistent game plan for
future maintenance purposes though. Some folks like to separate their code a bit
so debugging and trouble-shooting problems is a little easier down the road.

Rich
--
Basic Newsguy - 3 GB / month - $39.95 / year
http://newsguy.com/overview.htm

 

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

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