* Thus wrote [EMAIL PROTECTED]:
> Thanks,
> But im using php 4.3.
Then you'll have to resort to some very unstandard methods:
class foo {
var $instance_manager;
function getInstanceNum() {
return $this->instance_manager->instancesOf(__CLASS__);
}
function getInstanceName() {
return __CLASS__;
}
}
class Factory {
var $instances;
function &create($name) {
$this->instances[$name]++; // keep track of instances.
$new = new $name(); // create object
$new->instance_manager = &this; // tell instance about me
return &$new; // return value.
}
function destroy(&$obj) {
$this->instances[$this->getInstanceName()]--;
unset($obj);
}
function instancesOf($name) {
return $this->instance[$name];
}
}
$Factory = new Factory();
$o = &$Factory->Crate('foo');
echo $o->getIntanceNum();
$Factory->destroy($o);
btw, totally untested.
Curt
--
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about. No, sir. Our model is the trapezoid!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php