Skip to content

Instantly share code, notes, and snippets.

@paulbarbu
Created May 1, 2011 14:14
Show Gist options
  • Save paulbarbu/950527 to your computer and use it in GitHub Desktop.
Save paulbarbu/950527 to your computer and use it in GitHub Desktop.
an exercise from #yap book
<?php
/**
* void render(string $template, array $vars = NULL)
*
*/
function render($template, $vars = NULL){
if($vars != NULL){
foreach($vars as $name => $val){
$$name = $val;
}
}
include $template;
}
function render_extract($template, $vars = NULL){
if($vars != NULL){
extract($vars);
}
include $template;
}
if(isset($_POST['nume']) && is_string($_POST['nume'])){
$nume = $_POST['nume'];
}
if(isset($nume)){
render_extract('greet_nume.php', array('nume' => $nume));
}
else{
include 'greeting_form.php';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment