xref: /PHP-5.3/tests/classes/visibility_005.phpt (revision 610c7fbe)
1--TEST--
2ZE2 foreach and property visibility
3--FILE--
4<?php
5
6class base
7{
8	public $a=1;
9	protected $b=2;
10	private $c=3;
11
12	function f()
13	{
14		foreach($this as $k=>$v) {
15			echo "$k=>$v\n";
16		}
17	}
18}
19
20class derived extends base
21{
22}
23
24$o = new base;
25$o->d = 4;
26echo "===base::function===\n";
27$o->f();
28echo "===base,foreach===\n";
29foreach($o as $k=>$v) {
30	echo "$k=>$v\n";
31}
32
33$o = new derived;
34$o->d = 4;
35echo "===derived::function===\n";
36$o->f();
37echo "===derived,foreach===\n";
38foreach($o as $k=>$v) {
39	echo "$k=>$v\n";
40}
41
42?>
43--EXPECT--
44===base::function===
45a=>1
46b=>2
47c=>3
48d=>4
49===base,foreach===
50a=>1
51d=>4
52===derived::function===
53a=>1
54b=>2
55c=>3
56d=>4
57===derived,foreach===
58a=>1
59d=>4
60