public function __construct($template = '', array $data = array())
{
if ($template !== '') {
$this->setTemplate($template);
}
if (!empty($data)) {
foreach ($data as $name => $value) {
$this->$name = $value;
}
}
}
Got this from the devshed composite view tutorial (http://www.devshed.com/c/a/PHP/PHP-Composite-View-Design-Pattern-Introducing-the-Key-Concepts/1/). Anyway, I'm a bit confuse on, $this->$name = $value; statement.
I usually use $this for class's properties and/or when invoking class's methods within the said class. Plus the statement have two $'s. Which is weird! So is $this->$name = $value referring to the $name defined in the foreach loop? If so can someone explain this usage or logic behind this?
Thank you in advance.