(Yaf >=1.0.0)
Yaf_View_Simple::assignRef — The assignRef purpose
public Yaf_View_Simple::assignRef ( string $name , mixed &$value ) : bool
unlike Yaf_View_Simple::assign(), this method assign a ref value to engine.
name
A string name which will be used to access the value in the tempalte.
value
mixed value
Example #1 Yaf_View_Simple::assignRef()example
<?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); } ?>
Example #2 template()example
<html> <head> <title><?php echo $foo; $foo = "changed"; ?></title> </head> <body> </body> </html>
The above example will output something similar to:
/* access the index controller will result: */ changed
© 1997–2020 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://www.php.net/manual/en/yaf-view-simple.assignref.php