title: assigning variables to MVC view class?
body: <p>i'm building a simple php MVC with MVC basic concept</p>
  
  <p>while building the view class i tried to built a simple function which let me pass variables from the controller to the view</p>
  
  <pre><code>&lt;?php
  
  class View {
      protected $data = array();
  
      function __construct() {
          //echo 'this is the view';
      }
      public function assign($variable , $value)
      {
          $this-&gt;data[$variable] = $value;
      }
  
      public function render($name, $noInclude = false)
      {
          extract($this-&gt;data);
          if ($noInclude == true) {
              require 'views/' . $name . '.php';    
          }
          else {
              require 'views/header.php';
              require 'views/' . $name . '.php';
              require 'views/footer.php';    
          }
      }
  
  
  }
  </code></pre>
  
  <p>in my controller class i used to use like this</p>
  
  <pre><code>class Index extends Controller {
  
      function __construct() {
          parent::__construct();
      }
  
      function index() {
          $this-&gt;view-&gt;assign('title','welcome here codes');
          $this-&gt;view-&gt;render('index/index',true);
      }
  </code></pre>
  
  <p>the render function just working fine but there is a problem with the assign function because when i tried to print out the variable from the view it shows nothing</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;title&gt;Test Code&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;? echo $title;?&gt; 
  some text here
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>i tried to change the protected variable within the View class to public but it didn't effect the problem and i still can't print out any variables from the controller</p>