bug29368_1.phpt 462 B

1234567891011121314151617181920212223242526272829
  1. --TEST--
  2. Bug #29368.1 (The destructor is called when an exception is thrown from the constructor).
  3. --FILE--
  4. <?php
  5. function throwme($arg)
  6. {
  7. throw new Exception;
  8. }
  9. class foo {
  10. function __construct() {
  11. echo "Inside constructor\n";
  12. throwme($this);
  13. }
  14. function __destruct() {
  15. echo "Inside destructor\n";
  16. }
  17. }
  18. try {
  19. $bar = new foo;
  20. } catch(Exception $exc) {
  21. echo "Caught exception!\n";
  22. }
  23. ?>
  24. --EXPECT--
  25. Inside constructor
  26. Caught exception!