Skip to content

Instantly share code, notes, and snippets.

Created March 29, 2010 17:40
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
PHP Template Rendering
class MissingTemplateException extends Exception {}
function render_template($template_file, $vars = array())
return ob_get_clean();
throw new MissingTemplateException("Template: {$template_file} could not be found!");
function my_action()
$name = 'Rob';
$company = 'Globalcom';
return render_template('template.phtml', array('name' => $name, 'company' => $company));
echo my_action(); // => "Hello Rob! You work at Globalcom, don't you?"
Hello <?= $name ?>! You work at <?= $company ?>, don't you?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment