Ben temelde bu gibi görünen bir sınıf var:
class App {
public function newTemplate($filename, $vars=array())
{
$smarty = new Smarty;
$smarty->compile_dir = $this->template_compile_path;
if(count($vars) > 0)
{
foreach($vars as $v_key => $v_name)
{
$smarty->assign($v_key, $v_name);
}
}
return $smarty;
}
}
Ben 'App' bir örneği oluşturduğunuzda Ancak, $ smarty için referans membermethods çağrısı her şey görünmüyor gibi, kırık gibi görünüyor:
$app = new App;
$tpl = $app->newTemplate("index.tmpl");
$tpl->assign("foo", "bar"); // {$foo} does not appear with "bar" in the template
Şimdi neden acaba? Tabii ki başvuruları kullanmak için çalıştı:
...
public function &newTemplate()
...
... Ama bu işe yaramazsa. Değişken referanslar ya da çalışmak için görünmüyor:
...
$tpl = &$app->newTemplate("index.tmpl");
...
Ne uygun bir başvuru döndürmek için burada PHP neden oluyor? Yardım çok takdir!