note 46208 added to language.oop5.iterations

From: Date: Sat, 02 Oct 2004 12:29:36 +0000
Subject: note 46208 added to language.oop5.iterations
Groups: php.notes 
Request: Send a blank email to php-notes+get-77739@lists.php.net to get a copy of this message
The properties visible when iterating depend on the current scope. A protected property will be visible when iteration occurs within a child object. Private properties are visible within the declaring class. e.g.: class testIterator { private $private1; private $private2; public $public1; public $public2; protected $protected1; protected $protected2; public function __construct() { $this->private1="private 1"; $this->private2="private 2"; $this->public1="public 1"; $this->public2="public 2"; $this->protected1="protected 1"; $this->protected2="protected 2"; foreach ($this as $key=>$value) { print "$key : $value<br />"; } } } $test=new testIterator; will output: private1 : private 1 private2 : private 2 public1 : public 1 public2 : public 2 protected1 : protected 1 protected2 : protected 2 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.iterations.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+46208 Delete -- http://master.php.net/manage/user-notes.php?action=delete+46208&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+46208&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#77739) next »