Return to visibility_005.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / tests / classes |
1.1 ! misho 1: --TEST-- ! 2: ZE2 foreach and property visibility ! 3: --FILE-- ! 4: <?php ! 5: ! 6: class 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: ! 20: class derived extends base ! 21: { ! 22: } ! 23: ! 24: $o = new base; ! 25: $o->d = 4; ! 26: echo "===base::function===\n"; ! 27: $o->f(); ! 28: echo "===base,foreach===\n"; ! 29: foreach($o as $k=>$v) { ! 30: echo "$k=>$v\n"; ! 31: } ! 32: ! 33: $o = new derived; ! 34: $o->d = 4; ! 35: echo "===derived::function===\n"; ! 36: $o->f(); ! 37: echo "===derived,foreach===\n"; ! 38: foreach($o as $k=>$v) { ! 39: echo "$k=>$v\n"; ! 40: } ! 41: ! 42: ?> ! 43: --EXPECT-- ! 44: ===base::function=== ! 45: a=>1 ! 46: b=>2 ! 47: c=>3 ! 48: d=>4 ! 49: ===base,foreach=== ! 50: a=>1 ! 51: d=>4 ! 52: ===derived::function=== ! 53: a=>1 ! 54: b=>2 ! 55: c=>3 ! 56: d=>4 ! 57: ===derived,foreach=== ! 58: a=>1 ! 59: d=>4