note 119898 added to language.oop5.overloading
| From: | pogregoire##live.fr | Date: | Fri, 16 Sep 2016 16:17:58 +0000 |
| Subject: | note 119898 added to language.oop5.overloading | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-206605@lists.php.net to get a copy of this message | ||
It is important to understand that encapsulation can be very easily violated in PHP. for example :
class Object{
}
$Object = new Object();
$Objet->barbarianProperties = 'boom';
var_dump($Objet);// object(Objet)#1 (1) { ["barbarianProperties"]=> string(7)
"boom" }
Hence it is possible to add a propertie out form the class definition.
It is then a necessity in order to protect encapsulation to introduce __set() in the class :
class Objet{
public function __set($name,$value){
throw new Exception ('no');
}
}
----
Server IP: 72.52.91.14
Probable Submitter: 2a01:e34:ec1f:2450:7588:99f5:8ce3:3de9
----
Manual Page -- http://php.net/manual/en/language.oop5.overloading.php
Edit -- https://master.php.net/note/edit/119898
Del: integrated -- https://master.php.net/note/delete/119898/integrated
Del: useless -- https://master.php.net/note/delete/119898/useless
Del: bad code -- https://master.php.net/note/delete/119898/bad+code
Del: spam -- https://master.php.net/note/delete/119898/spam
Del: non-english -- https://master.php.net/note/delete/119898/non-english
Del: in docs -- https://master.php.net/note/delete/119898/in+docs
Del: other reasons-- https://master.php.net/note/delete/119898
Reject -- https://master.php.net/note/reject/119898
Search -- https://master.php.net/manage/user-notes.php