« Yaf_View_Simple
Yaf_View_Simple::assignRef »

Yaf_View_Simple::assign

(Yaf >=1.0.0)

Yaf_View_Simple::assign — 値を代入する

説明

public function Yaf_View_Simple::assign(string $name, mixed $value = ?): bool

変数をビューエンジンに代入します。

パラメータ

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 テンプレートの例

<html>
 <head>
  <title><?php echo $foo; ?></title>
 </head>  
<body>
  <?php 
    foreach ($this->_tpl_vars as $name => $value) {
         echo $$name; // or echo $this->_tpl_vars[$name];
    }
  ?>
</body>
</html>

参考

関連キーワード:
View   assign   代入   assignRef   エンジン   head   title   body   vars   mixed   変数   ビュー   必須   IndexController   extends   Controller   Abstract   indexAction   getView   view   テンプレート   foreach   参考   Interface   clear
関連する関数・ページ:
yaf-view-simple.set   yaf-view-simple.assignref   yaf-view-simple.clear   class.yaf-view-simple   yaf-view-interface.assign   yaf-view-simple.construct