update : 2015.11.03
php.shukuma.com

검색:
 
 
The assignRef purpose

Yaf_View_Simple::assignRef

(Yaf >=1.0.0)

Yaf_View_Simple::assignRefThe assignRef purpose

설명

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

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>

위 예제의 출력 예시:

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

참고