Help with classes in php

Help with classes in php

class Controller {      protected $_controller;     protected $_action;     protected $_template;      public $doNotRenderHeader;     public $render;      function __construct($controller, $action) {          $this->_controller = ucfirst($controller);         $this->_action = $action;         $model = ucfirst($controller);/* Conecting the model  class*/         $this->doNotRenderHeader = 0;         $this->render = 1;         $modelName = ucfirst($model).'Model';         new $modelName;         $this->_template = new Template($controller,$action);      }      function set($name,$value) {         $this->_template->set($name,$value);     }       function __destruct() {         if ($this->render) {             $this->_template->render($this->doNotRenderHeader);         }     }  } 

I'm a newbie in working with classes , i don't understand so much , i want to implement and to study to work with classes this example of mvc structure , but i have a problem , with function set I'm saving into array , some information and then to sent inside class template , when i using inside function __construct I'm sending with set() function that have the role to save data into $this_template object, it's working ok , but when i'm creating a new function in this class or extended class , is not working ...

The question is - how to do , when i create a function in Controller class , to set in array the value that i need , to work with them inside class template :) thanks very much for helping ..and sorry for my English

class Template {     protected $variables = array();   function set($name,$value) { 	$this->variables[$name] = $value; }       function render(){         extract($this->variables); print_r($this->variables);     } } 

I need with function set() from Class Controller to export data inside class Template , and why when i creating a function inside Class Controller ex :

function functionName() {    $data=array('a','b');    $this->set('data',$data); } 

and inside class Template , i putting print_r($this->variables); , and the array is empty

c++ templated friend class


C++ returning nested class with template on base class problem
__construct($controller, $action) {          $this->_controller = ucfirst($controller); ...} 
What exactly is the type of variable $controller? is is a string, perhaps? and should it be called "controller_name"?.
jquery: get elements by class name and add css to each of them
$model = ucfirst($controller);/* Conecting the model  class*/ ... 

Namespace and classes in php
$modelName = ucfirst($model).'Model';
Isn't the ucfirst redundant on the second line?.
Reference and Overwriting
new $modelName; 
should be .
Is there a way to force a classloader to load a package even if none of its classes have been loaded?
$this->somevariable = new Someclass($modelName); 
anyway, you have to go back to the drawing board and clean this up.

Using super with a class method
Perhaps this is too complex of an exercise for your first project using classes..
DataTables and custom types

70 out of 100 based on 80 user ratings 430 reviews