Skip to content

Instantly share code, notes, and snippets.

@ffub
Created March 22, 2015 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ffub/170f6942c00a2bf56b4d to your computer and use it in GitHub Desktop.
Save ffub/170f6942c00a2bf56b4d to your computer and use it in GitHub Desktop.
Partial function to limit include variable scope
/*
* Function name
*
* Super-crude way of limiting the variable scope of includes
*
* @file (string) The file to be included
* @vars (array) The variables to be available in the include
*/
function partial($file, $vars) {
extract($vars);
$backtrace = debug_backtrace();
$directory = dirname($backtrace['0']['file']);
require($directory . "/" . $file);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment