It doesn't work but I do not know why.
I would like it to work but do not know how to make it work.
Can I not use references like that?
Code: Select all
function Destroy(&$object)
{
if ( is_object($object) )
{
unset($object);
}
}Moderator: General Moderators
Code: Select all
function Destroy(&$object)
{
if ( is_object($object) )
{
unset($object);
}
}Code: Select all
$wrapper->destroy($wrapper->objects['test']);Code: Select all
function destroy($object)
{
$object->__destruct();
}I'm having trouble understanding that because it should only exist in one place, and is not being used in the script anywhere other than the service locator.feyd wrote:in some way short circuit any calls to other references to the object to, basically, self destruct as well.
Code: Select all
$this->object = $this->Instantiate($class_name, $args);
$this->objects[$object_name] = $this->object;
unset($this->object);Code: Select all
[feyd@home]>php -r "$arr = array(); class foo{} $foo = new foo(); $arr[] = $foo; function nil(&$o){$o = null;} var_dump($arr,$foo); nil($arr[0]); var_dump($arr,$foo);"
array(1) {
[0]=>
object(foo)#1 (0) {
}
}
object(foo)#1 (0) {
}
array(1) {
[0]=>
NULL
}
object(foo)#1 (0) {
}