<?php
// html output class
// if you were going to use this for a site i would recommend having it in
// an include file with these lines of code after the class creation:
// $htmlout = new htmlout;
// $htmlout->initialize('<sitedomain>', '<sitetitle>',);
// replace <sitedomain> with your site url and <sitetitle> with its default title.. eg Weberdev
// Free for use etc, if it is a personal site a link to www.co2busters.org would be heavily appreciated.
class htmlout {
//declare class variables
var $base_url;//Default Base url
var $site_name;//Title for entire site
function initialize($base_url, $site_name)
{//initialize class variables
$this->base_url = $base_url;
$this->site_name = $site_name;
}
function head($title, $keywords = '', $description = '')
{// does the html header for the page
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
function foot($time = 0)
{// does the html header for the page
if($time != 0){
echo '<p>'.date('r');
}
?>
</body>
</html>
<?
}
function print_link($name, $a, $def = true)
{// useful in many cases - for instance a domain change or dynamic menu
working
everywhere.
if($def = true)
{// Default
echo '<a href="'.$this->site_name.$a.'">'.$name.'</a>';
} else {// Incase you want to link elsewhere...
echo '<a href="'.$a.'">'.$name.'</a>';
}
}
function do_h($text, $hsize = 2)
{
echo '<h'.$hsize.'>'.$text.'</h'.$hsize.'>';
}
}
?>
Usage Example
<?php
$htmlout = new htmlout;
$htmlout->initialize('http://www.example.com', 'Cool stuff');
$htmlout->head('Home', $keywords = 'global, warming, climate, abatement, greenhouse,sequestration, pollution, solution, enviroment, sustainablity, ecology, waste',
$description = 'The Global Warming, Climate Change, Greenhouse Effect, Sequestration and Pollution Resource');
echo 'Tons of really interesting stuff etc. Blah Blah.<br>';
$htmlout->do_h('This is at the default heading size.');
$htmlout->do_h('This isn\'t.', 3);
$htmlout->do_h('Links!!', 1);
$htmlout->print_link('Example 1<br>', 'nonexistant.htm');
$htmlout->print_link('TecEco (CO2busters Sponsor)<br>', 'http://www.tececo.com', false);
$htmlout->print_link('CO2Busters (My Hobby Site!)<br>', 'http://www.co2busters.org', false);
$htmlout->foot(1);// footer with timestamp
?>