PHP Magic methods not working
- by user991047
I am trying to create a registry class with magic __set and __get my class looks like
class Registry {
private $vars = array();
public function __set($key, $value)
{
$this->vars[$key] = $value;
dump($key, $value);
}
public function __get($index)
{
$this->vars[$index];
}
}
but if i try to save some variable in registry class in gets only the $key the $value
is alway NULL.
here is the sample code how I am try to call this class
$registry = new registry;
$registry->router = $router;
$registry->title = "Welcome ";