我在 .tpl 文件中有以下 php 代码
{php}
class Test
{
public function uname()
{
$key = array(
'email' => '123@abc.com',
'domain' => 'example.com');
return $key;
}
public function passwd()
{
return 'password123';
}
}
$control = new Test();
{/php}
如何在 .tpl 文件中打印 $control->uname(( 和 $control->passwd(( 函数的输出?
首先将对象分配给 Smarty 全局对象。
$smartyObject->assign('control-passwd', $control->passwd());
然后你可以像往常一样输出它
{$control-passwd}