Skip to content

Instantly share code, notes, and snippets.

@ashwinreddy
Last active September 12, 2019 21:23
Show Gist options
  • Save ashwinreddy/6756627 to your computer and use it in GitHub Desktop.
Save ashwinreddy/6756627 to your computer and use it in GitHub Desktop.
<?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