Saturday, November 13, 2004

Include PHP code in HTML

PHP code can be added to any part of a HTML document.

For ease of maintenance, you can do the following:

<!-- start of html file -->

<?php

// Put in as much PHP code at the top of the document as possible.
$title = "This is the title of the webpage";
$body = "This is the body of the webpage";

// and more code ...

?>

<html>
<head>
<title><?php print($title); ?></title>
</head>
<body>

<?php print($body); ?>

</body>
</html>

<!-- end of html file -->

0 Comments:

Post a Comment

<< Home