note 79966 rejected from language.oop5.patterns by colder

From: Date: Fri, 21 Dec 2007 15:06:24 +0000
Subject: note 79966 rejected from language.oop5.patterns by colder
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-133853@lists.php.net to get a copy of this message
Note Submitter: seguro at unicar dot org dot ua ---- There is very interesting result of this script. Object created, but not saved in variable... Any ideas? <?php class Singletone { private static $instance; protected function __construct() { print 'class Singletone'; } public static function init($className=__CLASS__) { if(!isset(self::$instance)) self::$instance = new $className; return self::$instance; } } abstract class Session extends Singletone { } final class SessionMemcache extends Session { protected function __construct() { print('Session memcached'); } public static function init() { parent::init(__CLASS__); } public function test() { print 'TEST from SessionMemcache object'; } } $a = SessionMemcache::init(); //print msg from constructor $a->test(); //Fatal error: Call to a member function test() on a non-object ?>

« previous php.notes (#133853) next »