You are here: Re: Embedding the entire HTML within PHP « All PHP « IT news, forums, messages
Re: Embedding the entire HTML within PHP

Posted by Martin Jay on 05/18/06 14:16

In message <rbNag.3300$bW5.313@newsfe2-gui.ntli.net>, Domestos
<never.you@mind.?.invalid> writes
>I am currently writing pages that are pure PHP. i.e. they begin with the
><?php symbol.
>
>I am embedding all the HTML within echo ' ' commands even the <HTML> <HEAD>
>and <BODY> tags
>
>i..e.
>
><?php
>echo '<HTML><HEAD><TITLE>Title</TITLE></HEAD><BODY></BODY></HTML>';
>?>
>
>Is this the right way to do things? or should I be embedding PHP into the
>HTML page?

The second option is probably the easiest way to do things. It will
make your documents easier to follow and debug too.

For example:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>
<title>Hello World</title>
</head>

<body>

<?php echo "Hello world"; ?>

</body>
</html>

Sometimes it is convenient to include HTML within PHP, for example:

[some PHP]

echo "<p>".$paragraph."</p>";

[more PHP]

IMO in this sort of case, where you want to just output a small amount
of HTML (<p> and </p>), it's easier to include it in an echo.
--
Martin Jay

 

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

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