Guest User

Untitled

a guest
Jul 22nd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. function theme($template_file, $v = array()) {
  2. if (!file_exists("./$template_file")) {
  3. return "[$template_file does not exist]";
  4. }
  5. if (is_array($v)) {
  6. extract($v, EXTR_SKIP); // Extract the variables to a local namespace
  7. }
  8. ob_start(); // Start output buffering
  9. include "./$template_file"; // Include the template file
  10. $contents = ob_get_contents(); // Get the contents of the buffer
  11. ob_end_clean(); // End buffering and discard
  12. return $contents; // Return the contents
  13. }
Add Comment
Please, Sign In to add comment