Created
August 29, 2013 08:02
-
-
Save SKoschnicke/6375383 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Test { | |
private $number = 0; | |
private $sub; | |
public function __construct($n) { | |
$this->number = $n; | |
$this->sub = new SubTest($n, $this); | |
echo "construct ".$this->number."\n"; | |
} | |
public function release_childen() { | |
unset($this->sub); | |
} | |
public function __destruct() { | |
unset($this->sub); | |
echo "destruct ".$this->number."\n"; | |
} | |
} | |
class SubTest { | |
private $number = 0; | |
private $parent; | |
public function __construct($n, $parent) { | |
$this->number = $n; | |
$this->parent = $parent; | |
echo "subtest construct ".$this->number."\n"; | |
} | |
public function __destruct() { | |
echo "subtest destruct ".$this->number."\n"; | |
} | |
} | |
$a = new Test(1); | |
$a->__destruct(); | |
//$a->release_childen(); | |
$a = new Test(2); | |
echo "--- end of script ---\n"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment