note 113752 added to language.oop5.visibility
| From: | thcdesigning at gmail dot com | Date: | Tue, 26 Nov 2013 12:51:01 +0000 |
| Subject: | note 113752 added to language.oop5.visibility | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-197639@lists.php.net to get a copy of this message | ||
Private or not private?
I get baffled whenever I see this kind of an example.
<?php
class vessel{
private $things = array();
public function setThing($things){
$this->things = $things;
}
public function getThing($obj){
return $obj->things;
}
}
class smallVessel{
private $things = array();
public function setThing($things){
$this->things = $things;
}
public function getThing($obj){
return $obj->things;
}
}
$basket = new vessel();
$bucket = new vessel();
$bowl = new smallVessel();
$basket->setThing(array('wine' , 'water' , 'sugar'));
// returns the contents inside basket unexpectedly
print_r($bucket->getThing($basket));
// returns error, quite rightly so!
print_r($bowl ->getThing($basket));
----
Server IP: 72.52.91.14
Probable Submitter: 72.52.91.14
----
Manual Page -- http://php.net/manual/en/language.oop5.visibility.php
Edit -- https://master.php.net/note/edit/113752
Del: integrated -- https://master.php.net/note/delete/113752/integrated
Del: useless -- https://master.php.net/note/delete/113752/useless
Del: bad code -- https://master.php.net/note/delete/113752/bad+code
Del: spam -- https://master.php.net/note/delete/113752/spam
Del: non-english -- https://master.php.net/note/delete/113752/non-english
Del: in docs -- https://master.php.net/note/delete/113752/in+docs
Del: other reasons-- https://master.php.net/note/delete/113752
Reject -- https://master.php.net/note/reject/113752
Search -- https://master.php.net/manage/user-notes.php