xref: /PHP-7.2/Zend/tests/try/catch_002.phpt (revision 25d327e5)
1--TEST--
2Catching an exception in a constructor
3--FILE--
4<?php
5
6class MyObject
7{
8	function __construct()
9	{
10		throw new Exception();
11		echo __METHOD__ . "() Must not be reached\n";
12	}
13
14	function __destruct()
15	{
16		echo __METHOD__ . "() Must not be called\n";
17	}
18}
19
20try
21{
22	new MyObject();
23}
24catch(Exception $e)
25{
26	echo "Caught\n";
27}
28
29?>
30===DONE===
31--EXPECT--
32Caught
33===DONE===
34