Yaf_View_Simple::assign

(Yaf >=1.0.0)
Assign values
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

Returns:
Examples:
Yaf_View_Simple::assign() example
1
2
3
4
5
6
7
<?php
class IndexController extends Yaf_Controller_Abstract {
    public function indexAction() {
        $this->getView()->assign("foo""bar");
        $this->_view->assign( array"key" => "value""name" => "value"));
    }
?>
template() example
1
2
3
4
5
6
7
8
9
10
11
12
<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:

Yaf_View_Simple::assignRef() -

Yaf_View_Simple::__set() -

doc_php
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.