Skip to content

Instantly share code, notes, and snippets.

@SKoschnicke
Created August 29, 2013 08:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SKoschnicke/6375383 to your computer and use it in GitHub Desktop.
Save SKoschnicke/6375383 to your computer and use it in GitHub Desktop.
<?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