HeadFoot.php HTML template

A minimalist html template, for creating full html pages using php.

About

headfoot.php is a html page template for php. It produces the initial as well as the finishing html for a page, known as "header" and "footer" respectively.

This software may be used as a quick way to do a "mock-up" for a web development project, or it may be used as part of a fully functional web site.

Usage

Basic use

Usage is very simple: To use "headfoot.php", first download the php file. Then, include it in your project and call the function hf();.

A full html page may be created like this:

PHP code Generated HTML code

   <?php
   include_once("headfoot.php");

   hf("h");
   echo "hello world";
   hf("f");
   ?>
               

   <!DOCTYPE html>
   <html lang="en">
   <head>
      <title>untitled</title>
      <meta http-equiv="content-type" content="text/html;charset=utf-8">
   </head>
   <body>
      <h1>untitled</h1>
   hello world</body>
   </html>
               

The lines above will produce the minimum amount of html required to display a full html page. In the example, the page text will be "hello world".

For information on advanced use (as well as the origins of the "untitled" word), see "Documentation" below

Documentation

Advanced use

There are no limits to the complexity of pages that this small script may support, as you are free to modify it entirely to suit your particular purposes and preferences. Without further customization the script supports the following features:

Calling the script

The full set of options for calling the script are:

hf($what, $p_title='', $meta_robots='', $meta_kwd='', $meta_desc='', $css_url='', $js_url='', $xtra='')

First variable: $what (required)

The first variable $what is the only required variable. It must be set to one of two values: "header", or "footer". However, there is some freedom of expression:

Valid header callsValid footer calls
hf("h"); hf("f");
hf("head"); hf("foot");
hf("header"); hf("footer");
hf("top"); hf("bottom");
hf("start"); hf("end");
The "$p_title" variable
variabledescription / example
$p_titlePage title and headline. Default "untitled"
<title>$p_title</title>
<h1>$p_title</h1>

The default page title is "untitled". This title is used when the variable $p_title has not been set to a value.

The optional variables

The script has the following optional variables:

variabledescription / example
$meta_robotsThe "robots" META tag
<meta name="robots" content="$meta_robots">
$meta_kwdThe "keywords" META tag
<meta name="keywords" content="$meta_kwd">
$meta_descThe "description" META tag
<meta name="description" content="$meta_desc">
$css_urlURL to included stylesheet
<link rel="stylesheet" type="text/css" media="screen" href="$css_url">
$js_urlURL to included javascript
<script type="text/javascript" src="$js_url">
$xtra(see below)
The "$xtra" variable

If the variables above are not sufficient, you may include additional content using the optional variable $xtra. This variable simply prints out whatever content it has into the <head> section of the page.

variabledescription / example
$xtraAn "extra" variable for what is not included in the variables above
<base target="_blank">
<meta name="copyright" content="©me-me-me-me!!!!!one1">

Extra global variables

Two extra variables exist. These have been made "globals" because it is little likely that they should change from one page to another.

variabledescription / example
$pg_langTwo-character language code for page. Default "en"
<html lang="$pg_lang">
$pg_charsetCharacter set code for page. Default "utf-8"
<meta http-equiv="content-type" content="text/html;charset=$pg_charset">

The default values are "en" and "utf-8" respectively. These values are used when the variables have not been set to a value.

Version and License

Version

Current version: 0.1

License

What? Free!

Source Code and Download

Source code

Please click the "download" link below and the full script will be visible as a plain text file: "headfoot.php.txt"

Download

headfoot.php.txt (1.7kB) (right-click the link, and choose "Save link/target as...")

IMPORTANT: After the download, rename the file to headfoot.php in order to use it. Feel free to choose any other name if that suits you better.

The extra ".txt" filetype extension was set to enable you to view the source code, it will not work in php.