Skip to content

Instantly share code, notes, and snippets.

@8ig8
Forked from tamagokun/HTML.php
Created August 18, 2013 02:09
Show Gist options
  • Save 8ig8/6259589 to your computer and use it in GitHub Desktop.
Save 8ig8/6259589 to your computer and use it in GitHub Desktop.
<?php
class HTML
{
public static function __callStatic($tag,$args)
{
$options = array_shift($args);
$content = ($args)? array_shift($args) : "";
return self::element($tag,$options,$content);
}
private static function element($tag,$options,$content)
{
$attrs = "";
foreach($options as $attr=>$option) $attrs .= "$attr=\"$option\" ";
return (self::self_closing($tag))? "<$tag $attrs/>" : "<$tag $attrs>$content</$tag>";
}
private static function self_closing($tag)
{
$inline = array("link","meta","img","input","br","hr");
return in_array($tag,$inline);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment