Created
March 22, 2015 16:11
-
-
Save ffub/170f6942c00a2bf56b4d to your computer and use it in GitHub Desktop.
Partial function to limit include variable scope
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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