【发布时间】:2011-01-26 06:48:38
【问题描述】:
class A
{
public $property1;
public $objB;
public __construct(){
$this->property1 = 'test';
$this->objB = new B();
}
}
class B
{
public $title;
public __construct(){
$this->title = 'title1';
}
}
所以现在我在 .php 文件中执行此操作
$a = new A();
在我的 .tpl 我想显示 $a->objB->title
我该怎么做?我试过了
$smarty->assign('a', $a);
我在 smarty 中无法做到这一点
{$a->objB->title}
我也试过了
$smarty->register_object('a', $a);
我在 smarty 中无法做到这一点
{a->objB->title}
或
{$a->objB->title}
请指教。
【问题讨论】:
-
每次我读到这些聪明的帖子,对我来说就像“我想骑自行车上楼梯到 22 楼,谁能帮忙”。那么,“让自行车站立行走”怎么样?对不起。
标签: php templates smarty variable-assignment