Currently, I have a Registry class where I store default and/or general variables that are used in several classes (for example, a variable containing the root path address). I have included the class below which simply contains a (1) set function and (2) get function. However, I would like to add a (3) third function to import preset default values from another settings file, such that I can do a $registry->import('/app/settings.ini') type thing.
Could someone help me do this? Regardless, thank you all for your help on these forums!
<?php
class Registry {
private $store = array();
public function __set($label, $object) {
if(!isset($this->store[$label]))
{
$this->store[$label] = $object;
}
}
public function __get($label) {
if(isset($this->store[$label]))
{
return $this->store[$label];
}
return false;
}
}
//Current example of usage
$registry = new Registry();
$registry->__set("Database Name", "mysql.internal");
echo $registry->__get("Database Name"); //Outputs "mysql.internal"
/* What I would like to add is some type of function that adds labels and objects from a settings file, so
something like::
$registry->import('/app/settings.ini');
*/
?>