bug29368.phpt 447 B

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