bug29368.phpt 427 B

12345678910111213141516171819202122232425262728293031323334
  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. ===DONE===
  27. --EXPECT--
  28. Foo::__construct
  29. Caught exception!
  30. ===DONE===