(Yaf >=1.0.0)
Yaf_View_Simple::assign — 指派值
name
字串或陣列。
如果是字串,則需要下一個參數 $value。
value
混合值
範例 #1 Yaf_View_Simple::assign() 範例
<?php
class IndexController extends Yaf_Controller_Abstract {
public function indexAction() {
$this->getView()->assign("foo", "bar");
$this->_view->assign( array( "key" => "value", "name" => "value"));
}
}
?>
範例 #2 template() 範例
<html>
<head>
<title><?php echo $foo; ?></title>
</head>
<body>
<?php
foreach ($this->_tpl_vars as $name => $value) {
echo $$name; // 或 echo $this->_tpl_vars[$name];
}
?>
</body>
</html>