我正在努力创建我自己的非常简单的 MVC,并且正在集思广益地想出从 Controller 到 View 的方法。这涉及将变量从一个类发送到一个普通的旧 PHP 页面。
我确信之前已经讨论过了,但我想看看人们能想出什么样的想法。
//this file would be /controller/my_controller.php
class My_Controller{
function someFunction(){
$var = 'Hello World';
//how do we get var to our view file in the document root?
//cool_view.php
}
}
最佳答案
某种哈希表是一种很好的方法。将您的变量作为关联数组返回,这将填补您 View 中的所有空白。
关于php - 从 Controller 到 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3561402/