文字

Yaf_View_Simple::assignRef

(Yaf >=1.0.0)

Yaf_View_Simple::assignRefThe assignRef purpose

说明

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

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

参数

name

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

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 );

        

        
$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>

以上例程的输出类似于:

changed

参见

  • Yaf_View_Simple::assign() - 为视图引擎分配一个模板变量
  • Yaf_View_Simple::__set() - 为视图引擎分配一个模板变量
上一篇: 下一篇: