1. <?php
  2. function tag($tag, $content = null, array $attributes = null) {
  3.  
  4.    $out = '<' . $tag;
  5.    if ($attributes !== null) {
  6.      foreach($attributes AS $key => $val) {
  7.        $out .= ' ' . $key . '="' . $val . '"';
  8.      }
  9.    }
  10.  
  11.    if ($content === null) {
  12.       return $out . ' />';
  13.    }
  14.  
  15.    return $out . '>' . $content . '</' . $tag . '>';
  16.  
  17. }
  18.  
  19. tag('h1', 'Header', array('class' => 'h1', 'id' => 'h1', 'style' => 'text-align:center;'));