Return to ctor_failure.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / tests / classes |
1.1 ! misho 1: --TEST-- ! 2: ZE2 Do not call destructors if constructor fails ! 3: --FILE-- ! 4: <?php ! 5: ! 6: class Test ! 7: { ! 8: function __construct($msg) { ! 9: echo __METHOD__ . "($msg)\n"; ! 10: throw new Exception($msg); ! 11: } ! 12: ! 13: function __destruct() { ! 14: echo __METHOD__ . "\n"; ! 15: } ! 16: } ! 17: ! 18: try ! 19: { ! 20: $o = new Test('Hello'); ! 21: unset($o); ! 22: } ! 23: catch (Exception $e) ! 24: { ! 25: echo 'Caught ' . get_class($e) . '(' . $e->getMessage() . ")\n"; ! 26: } ! 27: ! 28: ?> ! 29: ===DONE=== ! 30: --EXPECT-- ! 31: Test::__construct(Hello) ! 32: Caught Exception(Hello) ! 33: ===DONE===