gc_028.phpt 545 B

123456789101112131415161718192021222324252627282930313233
  1. --TEST--
  2. GC 028: GC and destructors
  3. --INI--
  4. zend.enable_gc=1
  5. --FILE--
  6. <?php
  7. class Foo {
  8. public $bar;
  9. function __destruct() {
  10. if ($this->bar !== null) {
  11. unset($this->bar);
  12. }
  13. }
  14. }
  15. class Bar {
  16. public $foo;
  17. function __destruct() {
  18. if ($this->foo !== null) {
  19. unset($this->foo);
  20. }
  21. }
  22. }
  23. $foo = new Foo();
  24. $bar = new Bar();
  25. $foo->bar = $bar;
  26. $bar->foo = $foo;
  27. unset($foo);
  28. unset($bar);
  29. var_dump(gc_collect_cycles());
  30. ?>
  31. --EXPECT--
  32. int(1)