【问题标题】:Modify smarty object by reference通过引用修改 smarty 对象
【发布时间】:2023-03-14 13:06:02
【问题描述】:

我在通过引用修改 smarty 变量时遇到问题。这是我想要做的:

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");

【问题讨论】:

    标签: php smarty pass-by-reference


    【解决方案1】:

    实际上是nvm,我在代码的其他地方犯了一个错误。上面的代码是正确的:P

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-12-06
      • 1970-01-01
      • 1970-01-01
      • 2017-10-21
      • 2012-06-04
      • 1970-01-01
      • 2012-01-29
      相关资源
      最近更新 更多