|
|
 |
In this article I will show you how to use the include() function to set up your HTML pages. Take a look at the code below.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="description" content="<? echo $description ?>">
<meta name="keywords" content="<? echo $keywords ?>">
<title><? echo $title ?></title> </head>
|
At first glance the code may appear to be merely HTML. However, upon closer examination you will notice there are a few PHP
variables. These variables will hold the page title, description, and keywords. This snippet will be saved as header.php
With the file above we can generate pages that have a title, description, and keywords by using the include() function. Take a
look at the code below.
<?
$title = "include() tutorial";
$description = "Use include() for HTML page setup";
$keywords = "php include, php include()";
include("header.php");
?>
<body>
</body>
</html>
|
All we have to do is set our variables and then call the include() function passing it the name of the header file.
I could have linked style sheets, more meta data, and/or JavaScript file links into the header.php file, but I chose to leave them
out for simplicity. There are also many other situations where include() may come in handy. One place I made good use of the
include() function was in the message board I wrote. I put all my functions into a single file and then just include() them.
There's not much else to say so I'm gonna wrap this up.
|
 |
 |