Annotation of embedaddon/php/tests/classes/destructor_and_globals.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: ZE2 accessing globals from destructor in shutdown
3: --FILE--
4: <?php
5: $test_cnt = 0;
6: $test_num = 0;
7:
8: function Show() {
9: global $test_cnt;
10: echo "Count: $test_cnt\n";
11: }
12:
13: class counter {
14: protected $id;
15:
16: public function __construct() {
17: global $test_cnt, $test_num;
18: $test_cnt++;
19: $this->id = $test_num++;
20: }
21:
22: public function Show() {
23: echo 'Id: '.$this->id."\n";
24: }
25:
26: // try protected here
27: public function __destruct() {
28: global $test_cnt;
29: $test_cnt--;
30: }
31:
32: static public function destroy(&$obj) {
33: $obj = NULL;
34: }
35: }
36: Show();
37: $obj1 = new counter;
38: $obj1->Show();
39: Show();
40: $obj2 = new counter;
41: $obj2->Show();
42: Show();
43: counter::destroy($obj1);
44: Show();
45: // or uncomment this line and it works
46: //counter::destroy($obj2);
47: echo "Done\n";
48: ?>
49: --EXPECT--
50: Count: 0
51: Id: 0
52: Count: 1
53: Id: 1
54: Count: 2
55: Count: 1
56: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>