Tutorials Question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
BJRocker
Forum Newbie
Posts: 2
Joined: Sun Aug 18, 2002 9:00 am

Tutorials Question

Post 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
conthox
Forum Commoner
Posts: 39
Joined: Tue Jun 25, 2002 1:44 pm
Location: Sweden

no and yes

Post 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.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
BJRocker
Forum Newbie
Posts: 2
Joined: Sun Aug 18, 2002 9:00 am

Post by BJRocker »

Thanks

twigletmac, conthox,

Rich
Post Reply