Yaf_View_Simple::assign

(Yaf >=1.0.0)

Yaf_View_Simple::assignAtribui valores

Descrição

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

Atribui valores ao mecanismo de visualização.

Parâmetros

name

Uma string ou um array.

Se for uma string, o argumento seguinte, $value, é obrigatório.

value

Valor (mixed).

Valor Retornado

Exemplos

Exemplo #1 Exemplo de 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"));
    }
}
?>

Exemplo #2 Exemplo de modelo

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

Veja Também