Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我创建了两种布局:一种用于登录页面,另一种用于站点的其余部分。登录后,我想将变量从登录控制器传递到 zf2 布局,但无法访问。
如何访问在控制器操作中创建的布局中的变量?
在控制器中执行此操作的一些方法:
$viewmodel = new ViewModel(); $viewmodel->setVariable('myvar', $myvar); return $viewmodel;
$this->layout()->myvar = $myvar;
<?php echo $this->myvar; ?>