从Controller到View

Mik*_*ike 5 php model-view-controller

我正在创建自己非常简单的MVC,我正在集思广益,从控制器到视图.这涉及将变量从类发送到普通的旧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

   }

}
Run Code Online (Sandbox Code Playgroud)

Łuk*_*.pl 1

某种哈希表是做到这一点的好方法。将变量作为关联数组返回,这将填补视图中的所有空白。