Yaf_View_Simple::assign

Yaf_View_Simple::assign

(Yaf >=1.0.0)

Yaf_View_Simple::assignAssign values

Description

public bool Yaf_View_Simple::assign ( string $name [, mixed $value ] )

assign variable to view engine

Parameters

name

A string or an array.

if is string, then the next argument $value is required.

value

mixed value

Return Values

Examples

Example #1 Yaf_View_Simple::assign()example

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

Example #2 template()example

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

See Also

© 1997–2017 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://secure.php.net/manual/en/yaf-view-simple.assign.php

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部