AD1ctive Posted November 23, 2009 Share Posted November 23, 2009 Hello everyone! I'm coding my own little cms at the moment and got a problem. First, however, I'll explain how it works: Theres one main class called CMS which initiates all the sub classes when constructed. Then CMS can be used to access other classes. This is an example Code: class CMS { public static $PAGE; // PUBLIC FUNCTION: __construct() // initiates the whole Yeha system // public function __construct() { $this->initPagePlugin(); } // PROTECTED FUNCTION: initPagePlugin() // sets object self::$PAGE if not set yet // protected function initPagePlugin() { if(!isset(self::$PAGE)) self::$PAGE = new PagePlugin(); } // STATIC FUNCTION: PAGE() // sets object self::$PAGE if not set yet and returns it // public static function PAGE() { //if(!isset(self::$PAGE)) self::initPagePlugin(); return self::$PAGE; } } Later own all the functions of the class PagePlugin can be called using the command: CMS::PAGE()->exampleFunction(); This way works fine with all the sub classes, e.g. Database, Template, etc but not with the one above: "PagePlugin". For some reason PagePlugin is being constructed but not the object $PAGE. Consequently, I can't call PagePlugin's functions later on. Have u got an idea what's wrong? Thanks for your help Link to comment https://forums.phpfreaks.com/topic/182686-class-object-is-null-although-class-has-been-constructed/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.