-
-
Save 8ig8/6259589 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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