Yaf_View_Simple::assignRef

(Yaf >=1.0.0)

Yaf_View_Simple::assignRefThe assignRef purpose

说明

public Yaf_View_Simple::assignRef(string $name, mixed &$value): bool

不同于 Yaf_View_Simple::assign(),这个方法传递一个引用变量给模板引擎。

参数

name

字符串名,被用来传递值给模板。

value

混合值

返回值

示例

示例 #1 Yaf_View_Simple::assignRef() 示例

<?php
class IndexController extends Yaf_Controller_Abstract {
public function
indexAction() {
$value = "bar";
$this->getView()->assign("foo", $value);

/* plz note that there was a bug before Yaf 2.1.4,
* which make following output "bar";
*/
$dummy = $this->getView()->render("index/index.phtml");
echo
$value;

//prevent the auto-render
Yaf_Dispatcher::getInstance()->autoRender(FALSE);
}
}
?>

示例 #2 template()example

<html>
<head>
<title><?php echo $foo; $foo = "changed"; ?></title>
</head>
<body>
</body>
</html>

以上示例的输出类似于:

/* access the index controller will result: */
changed

参见

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top