note 73897 added to language.oop5.visibility

From: Date: Wed, 14 Mar 2007 20:32:58 +0000
Subject: note 73897 added to language.oop5.visibility
Groups: php.notes 
Request: Send a blank email to php-notes+get-124453@lists.php.net to get a copy of this message
When defining variable scope take the following example <?php class myClass { private $_SESSION; public function __construct(){ $_SESSION['TEST'] = "defined in class"; } } $test = new myClass; $_SESSION['TEST'] = "DEFINED OUTSIDE THE VISIBILITY"; echo $_SESSION['TEST']; ?> you would expect php to throw Fatal error: Cannot access private property myClass but it dosent. I thought that this was with any global variables but in the following: <?php global $test; class myClass { private $test; public function __construct(){ $test = "defined in class"; } } $test = new myClass; $test->test = "cant do"; ?> It throws the fatal error. ---- Server IP: 64.71.164.2 Probable Submitter: 206.34.186.161 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.visibility.php Edit -- https://master.php.net/note/edit/73897 Del: integrated -- https://master.php.net/note/delete/73897/integrated Del: useless -- https://master.php.net/note/delete/73897/useless Del: bad code -- https://master.php.net/note/delete/73897/bad+code Del: spam -- https://master.php.net/note/delete/73897/spam Del: non-english -- https://master.php.net/note/delete/73897/non-english Del: in docs -- https://master.php.net/note/delete/73897/in+docs Del: other reasons-- https://master.php.net/note/delete/73897 Reject -- https://master.php.net/note/reject/73897 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#124453) next »