I would like to ask about the PHP clone / copy object variable $ this.
I'm currently new to MVC, I would like to do something like CodeIgniter.
I would like to direct access to a variable.
in my __construct (), I always pass the global variable inside the new controller (class),
eg.
function __construct($mvc)
{
$this->mvc = $mvc;
}
inside the $ mvc configuration object, the vars object.
for example now
function index()
{
$this->mvc->config['title'];
$this->mvc->vars['name'];
}
** what i want is more direct **
function index()
{
$this->config['title'];
$this->vars['name'];
}
I tried
function __construct($mvc)
{
$this = $mvc;
}
or
function __construct($mvc)
{
$this = clone $mvc;
}
it is not successful. any idea i can close $ this-> mvc to $ this level? I also try not to succeed. Please help, thanks!
source
share