note 73977 deleted from language.oop5.visibility by bobby
| From: | bobby@php.net | Date: | Mon, 19 Mar 2007 17:24:59 +0000 |
| Subject: | note 73977 deleted from language.oop5.visibility by bobby | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-124593@lists.php.net to get a copy of this message | ||
Note Submitter: Evan B
----
In response to creeves at dja dot com:
You're code is all wrong when working with the _SESSION variable. In your first example
you're totally missing the scope. You've delcared _SESSION as a local private variable to
myClass but then you access it as the super global. You code should've been:
<?php
class myClass {
private $_SESSION;
public function __construct(){
$this->_SESSION['TEST'] = "defined in class";
}
}
$test = new myClass;
$test->_SESSION['TEST'] = "DEFINED OUTSIDE THE VISIBILITY";
echo $test->_SESSION['TEST'];
?>
Which does indeed throw:
Cannot access private property myClass::$_SESSION