Page 1 of 1

Tutorials Question

Posted: Sun Aug 18, 2002 9:00 am
by BJRocker
Hi All,

I've been reading the Tutorials about "Making Templates with PHP and Include() -- by enygma" & have a few question.

when you write & build the header/footer.php file's do they need to be wraped with a php tag or something ?

i.e. file code below, save as header.php

<?php
<html>
<title>Test Template</title>
<body bgcolor="white">\
<img src="logo.jpg">
?>

Then when you include your header/footer files within your .php pages i.e. index.php as the code below:

<?include("header.php");?>
this is the sample content
<?include("footer.php");?>

could these files "header/footer" be placed within a folder i.e. <?include("foldernamehere/header.php");?>

Also how does the code within <head> tag work ? if I built a page that needs the code within the head for i.e. drop down menus from http://www.projectseven.com will the browers see the code to display the page right.

So I would end with following page code for index.php:

<html>
<head>
</head>
<body>
<?include("foldername/header.php");?>
this is the sample content
<?include("foldername/footer.php");?>
</body>
</html>


Thanks Rich

no and yes

Posted: Sun Aug 18, 2002 9:54 am
by conthox
The included files does NOT have to be inside a <?php .. ?> tag.

It may contain whatever you want.

And yes, the included files may be in a different folder.

Posted: Sun Aug 18, 2002 11:20 am
by twigletmac
You only need to put PHP code within <?php ?> tags not HTML.

It's also best to use <?php ?> instead of <? ?> tags since it makes it easier to see where your PHP is and is the most widely supported format.

Mac

Posted: Sun Aug 18, 2002 1:22 pm
by BJRocker
Thanks

twigletmac, conthox,

Rich