Search Results

Search found 1 results on 1 pages for 'jamalali81'.

Page 1/1 | 1 

  • PHP Overloading, singleton instance

    - by jamalali81
    I've sort of created my own MVC framework and am curious as to how other frameworks can send properties from the "controller" to the "view". Zend does something along the lines of $this->view->name = 'value'; My code is: file: services_hosting.php class services_hosting extends controller { function __construct($sMvcName) { parent::__construct($sMvcName); $this->setViewSettings(); } public function setViewSettings() { $p = new property; $p->banner = '/path/to/banners/home.jpg'; } } file: controller.php class controller { public $sMvcName = "home"; function __construct($sMvcName) { if ($sMvcName) { $this->sMvcName = $sMvcName; } include('path/to/views/view.phtml'); } public function renderContent() { include('path/to/views/'.$this->sMvcName.'.phtml'); } } file: property.php class property { private $data = array(); protected static $_instance = null; public static function getInstance() { if (null === self::$_instance) { self::$_instance = new self(); } return self::$_instance; } public function __set($name, $value) { $this->data[$name] = $value; } public function __get($name) { if (array_key_exists($name, $this->data)) { return $this->data[$name]; } } public function __isset($name) { return isset($this->data[$name]); } public function __unset($name) { unset($this->data[$name]); } } In my services_hosting.phtml "view" file I have: <img src="<?php echo $this->p->banner ?>" /> This just does not work. Am I doing something fundamentally wrong or is my logic incorrect? I seem to be going round in circles at the moment. Any help would be very much appreciated.

    Read the article

1