Last active
September 12, 2019 21:23
-
-
Save ashwinreddy/6756627 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Template { | |
public static $vars = array(); | |
public static function bind($key, $value) { | |
self::$vars[$key] = $value; | |
} | |
public static function render($name) { | |
$contents = file_get_contents($name.".php"); | |
foreach (self::$vars as $key => $value) { | |
$contents = preg_replace('/\['.$key.'\]/', $value, $contents); | |
} | |
eval(' ?> '.$contents.' <?php '); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment