Created
April 11, 2012 13:54
-
-
Save francescoagati/2359446 to your computer and use it in GitHub Desktop.
simple dependency load in php with require and extract
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
<? | |
return array("a" => $title); |
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 dependency($path,$opts) { | |
extract($opts); | |
return require($path); | |
}; | |
$obj=dependency("include.php",array("title" => "ciao titolo")); | |
print_r($obj); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
extract explode the hash opts in local scope of dependency
require share the scope of function dependency
the object returned from the included file is passed the return of the dependency function