title: Custom MVC, how to implement a render function for the controller so the View can access variables set by the Controller
body: <p>I'm adding new features to an existing code base. Anyway, the current feature I'm doing should be in MVC in my opinion. The existing code base isn't MVC but the feature I'm implementing, I want it to be MVC. And I don't want to roll some existing MVC into the existing codes.</p>
  
  <p>So, my problem is... I don't know to implement a render function for the controller class. Usually, in MVC you have the controller do some stuff, set it to a variable using a render function, and the View can now magically access that given variable set by the controller.</p>
  
  <p>I have no idea how to do this other than global, which just feel wrong, I keep on telling myself there has to be a better way. Edit: It's global isn't it? >_> How does those other frameworks do it?</p>
  
  <p>Here's a silly example:</p>
  
  <p>Controller:</p>
  
  <pre><code>class UserController extend BaseController 
  {
  public function actionIndex() 
  {
    $User = new User; // create a instance User model
  
    $User-&gt;getListofUser();
  
    $this-&gt;render('ListOfUser', 'model'=&gt;$model);
  }
  }
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>&lt;?php
  //I can use $ListOfUser now...
  //some for loop
  echo $ListofUser[$i];
  ?&gt;
  </code></pre>
  
  <p>Thank you in advance!</p>