We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

the setVar() and setVars() not Work!

Controller code

public function indexAction() 
  {
      $this->view->setLayout('mainlogin');
      $this->view->setVar('test','hellWord');   
  }

View code in index.phtml:

<?php
    echo $test;
?>

the wrong message:

    Notice: Undefined variable: test in /data/wwwroot/shop/themes/views/backend/login/index.phtml on line 2

my php version is php 7,phalcon version is 2.1.