note 58943 added to language.oop5.basic

From: Date: Mon, 21 Nov 2005 17:48:37 +0000
Subject: note 58943 added to language.oop5.basic
Groups: php.notes 
Request: Send a blank email to php-notes+get-98894@lists.php.net to get a copy of this message
Hello firends When we discuss about OOP ,There is something that we name "encapsulation". Please pay attention to this code: <?php $global_obj=null; class my_class { var $value; var $g; function my_class() { global $global_obj; $global_obj=&$this; } } $a= new my_class(); $a->my_value=5; $global_obj->my_value=10; cho $a->my_value; ?> As you see, my_value is not member of my_class,But it can be used by $a That is an instance of my_class,Why a variable that is not defined in class and is from out of class can be accessible by in stance of that class? Isn't it one of weak point of PHP's OOP? With Regards Amir Hossein Estakhrian ---- Manual Page -- http://www.php.net/manual/en/language.oop5.basic.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+58943 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58943&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58943&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58943&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58943&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58943&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58943&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58943&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+58943&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#98894) next »