开发者

Modify smarty object by reference

开发者 https://www.devze.com 2022-12-14 04:44 出处:网络
I am having an issue modifying a smarty variable by reference.H开发者_如何学运维ere is what I am trying to do:

I am having an issue modifying a smarty variable by reference. H开发者_如何学运维ere is what I am trying to do:

class foo {
    $property;
    public function getProperty(){
        return $this->$property;
    }
    public function index(&$smarty){
        $smarty->assign('test',$this->getProperty());
    }
}


$smarty = new Smarty();
$foo = new foo();
$foo->index($smarty);

$smarty->display("test.tpl");


Actually nvm, I made a mistake somewhere else in the code. The above code is correct :P

0

精彩评论

暂无评论...
验证码 换一张
取 消