I have a render function that looks like:
function render($template, $values = array()){
   // if template exists, render it
   if (file_exists("../views/$template")){
      // extract variables into local scope
      extract($values);
      // render header_form
      require("../views/header_form.php");
      // render template
      require("../views/$template");
      // render footer
      require("../views/footer_form.php");
   }else{
      // else err
      trigger_error("Invalid template: $template", E_USER_ERROR);
   }
}
Suppose I have a script crew.php that looks like this:
<?php
    require('../includes/config.php');
        $values=[];           
        $today = new DateTime();
        render('crew_form.php',$values);
?>
Why don't I have access to $today in crew_form.php? For instance, if crew_form.php was:
<?php
    echo $today;
?>
When you use require doesn't that just add the script to the existing code? Is it because of local scope of the function render()?
 
     
    