gpt4 book ai didi

php - MVC : models interacts with the view?

转载 作者:可可西里 更新时间:2023-11-01 13:58:12 25 4
gpt4 key购买 nike

我知道一切都在通过 Controller 。

但我经常读到这样的文章:

  1. 用户与 View 交互
  2. Controller 要求模型改变它的状态
  3. 模型在状态改变时通知 View

我没有得到第三个。为什么说模型通知 View ,而实际上它通知 Controller 而 Controller 通知 View ?

最佳答案

这看起来更像是一个桌面系统,而不是像网站这样的无状态系统。

但也许它在谈论一些人如何喜欢从 View 中查询模型,例如

<?php foreach( $usersTableGateway->getUsers() as $user ): ?>
<?php echo $user ?><br>
<?php endforeach; ?>

我更喜欢在 Controller 中获取所有信息(在 Controller 中准备用户数组)并将其从 Controller 传递到 View 。

关于php - MVC : models interacts with the view?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2718682/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com