a simple and concise HTML tag builder class with support for dynamic attributes
include('class.tags.php');
echo new htmlTag('h1', null, "this is a header");
<h1>this is a header</h1>
echo new htmlTag('h1', array('class'=>'border pad right'), "this is a header");
<h1 class="border pad right">this is a header</h1>
$foo = new htmlTag('h1');
$foo->set_attr(array('class'=>'border pad right'));
$foo->content = "this is a header";
echo "{$foo}";
<h1 class="border pad right">this is a header</h1>
$foo = new htmlTag('h1');
$foo->set_attr(array('class'=>'border pad right'));
$foo->toggle_attr('class','pad');
$foo->content = "this is a header";
echo "{$foo}";
<h1 class="border right">this is a header</h1>
$foo = new htmlTag('h1');
$foo->set_attr(array('class'=>'border pad right'));
$foo->toggle_attr('class','foo');
$foo->content = "this is a header";
echo "{$foo}";
<h1 class="border pad right foo">this is a header</h1>
echo new htmlTag('br', array('class','clear'));
<br class="clear" />
$foo = new htmlTag('img');
$foo->set_attr('src','Example.jpg');
$foo->set_attr('alt','A picture of an Example');
$foo->toggle_attr('class','border');
echo "{$foo}";
<img src="Example.jpg" alt="A picture of an Example" class="clear foo" />
$img = new htmlTag('img');
$img->set_attr('src','Example.jpg');
$img->set_attr('alt','man in a hat');
$img->toggle_attr('class','border');
$div = new htmlTag('div');
$div->set_attr('class','border');
$div->content = $img;
echo "{$div}";
<div class="border"><img src="Example.jpg" alt="man in a hat" class="clear foo" /></div>