07-10-2008, 09:59 AM
|
#2 (permalink)
|
|
The Prestige
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
|
Just have accessor methods inside your child classes:
PHP Code:
<?php class factory { private static $pChild;
public static function getInstance($child) { if(!self::$pChild instanceof $child) { self::$pChild = new $child; }
self::$pChild->someVar = 'some value'; return self::$pChild; } } class child { private $someVar;
public function __set($key, $value) { if(in_array($this->$key, get_class_vars(__CLASS__))) { $this->$key = $value; } } public function __get($key) { if(isset($this->$key)) { return $this->$key; } return false; } }
$child = factory::getInstance('child'); echo $child->someVar;
That the kind of thing you are after?
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
|
|
|
|