<?php
function tag($tag, $content = null, array $attributes = null) {
$out = '<{$tag}';
if ($attributes !== null) {
foreach($attributes AS $key => $val) {
$out .= ' {$key}="{$val}"';
}
}
if ($content === null) {
return '{$out}/>';
}
return '{$out}>{$content}</{$tag}>';
}
tag('h1', 'Header', array('class' => 'h1', 'id' => 'h1', 'style' => 'text-align:center;'));