Skip to content

Instantly share code, notes, and snippets.

@francescoagati
Created April 11, 2012 13:54
Show Gist options
  • Save francescoagati/2359446 to your computer and use it in GitHub Desktop.
Save francescoagati/2359446 to your computer and use it in GitHub Desktop.
simple dependency load in php with require and extract
<?
return array("a" => $title);
<?
function dependency($path,$opts) {
extract($opts);
return require($path);
};
$obj=dependency("include.php",array("title" => "ciao titolo"));
print_r($obj);
@francescoagati
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment