note 46208 deleted from language.oop5.iterations by aidan

From: Date: Thu, 14 Oct 2004 22:23:17 +0000
Subject: note 46208 deleted from language.oop5.iterations by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-78557@lists.php.net to get a copy of this message
Note Submitter: rod[NOSPAM] at 23net dot net ---- 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

« previous php.notes (#78557) next »