note 73897 deleted from language.oop5.visibility by bobby

From: Date: Mon, 19 Mar 2007 17:25:10 +0000
Subject: note 73897 deleted from language.oop5.visibility by bobby
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-124594@lists.php.net to get a copy of this message
Note Submitter: creeves at dja dot com ---- 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.

« previous php.notes (#124594) next »