|
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]
|