I know that you can make headers and footers appear in documents using php, but how do you do this?
Announcement
Collapse
No announcement yet.
Headers and Footers
Collapse
X
-
Tags: None
-
Originally posted by newmand2
PHP Code:
include('header.php');
# site content
include('footer.php');
PHP Code:<?php
include('header.php');
<p>There is no spoon</p>
include('footer.php');
?>
PHP Code:<?php
<html>
<head>
<title>The Matrix</title>
</head>
<body>
?>
Comment
-
-
Originally posted by Error 404
So would my page be like this
PHP Code:<?php
include('header.php');
<p>There is no spoon</p>
include('footer.php');
?>PHP Code:<p>There is no spoon</p>
PHP Code:echo('<p>There is no spoon</p>');
PHP Code:<?php
echo('<html>');
echo('<head>');
echo('<title>The Matrix</title>');
echo('</head>');
echo('<body>');
?>
Hope that was helpfulDave
Comment
-
Or the preferred way...
PHP Code:<?php
include("header.php");
?>
<p>Blah blah blah</p>
<?php
include("footer.php");
?>
Code:<html> <head> etc etc
Just makes things easier for you and you should really avoid using php just to echo html as much as you can.
Comment
-
Nightfire's post was almost the way I did it, as I hadn't posted here yet.
PHP Code:<?PHP
$strPagetitle = 'Welcome';
require ('templates/header.php');
require ('indexcontents.html');
require ('templates/footer.php');
?>
Comment
-
Using php to echo html is pretty wateful. Part of the joy of using php is that you can intermix it in html. Instead of
PHP Code:<?php
include('header.php');
echo '<p>There is no spoon</p>';
include('footer.php');
?>
PHP Code:<?php include('header.php');?>
<p>There is no spoon</p>
<?php include('footer.php');?>
HTH.
Comment
-
On my site my header php file is:
PHP Code:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<title>The stubby web site</title>
<meta name="description" content= "Canadian Stubby Beer">
<meta name="keywords" content="stubby beer bottle">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
PHP Code:<hr></hr>
<center>
<?php
echo '© 2001-';
echo date('Y');
echo ' Leonard Whistler';
echo '<br>email: [email][email protected][/email]';
?>
</center>
<hr></hr>
</body>
</html>
Leonard Whistler
Last edited by Len Whistler; Feb 17, 2004, 02:56 PM.Leonard Whistler
Comment
Comment