xref: /PHP-7.2/tests/classes/ctor_dtor.phpt (revision a8d901a8)
1--TEST--
2ZE2 The new constructor/destructor is called
3--FILE--
4<?php
5
6class early {
7	function __construct() {
8		echo __CLASS__ . "::" . __FUNCTION__ . "\n";
9	}
10	function __destruct() {
11		echo __CLASS__ . "::" . __FUNCTION__ . "\n";
12	}
13}
14
15class late {
16	function __construct() {
17		echo __CLASS__ . "::" . __FUNCTION__ . "\n";
18	}
19	function __destruct() {
20		echo __CLASS__ . "::" . __FUNCTION__ . "\n";
21	}
22}
23
24$t = new early();
25$t->__construct();
26unset($t);
27$t = new late();
28//unset($t); delay to end of script
29
30echo "Done\n";
31?>
32--EXPECTF--
33early::__construct
34early::__construct
35early::__destruct
36late::__construct
37Done
38late::__destruct
39