note 73977 added to language.oop5.visibility
| From: | EvanB at osu1 dot php dot net | Date: | Mon, 19 Mar 2007 16:09:14 +0000 |
| Subject: | note 73977 added to language.oop5.visibility | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-124589@lists.php.net to get a copy of this message | ||
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
----
Server IP: 69.147.83.197
Probable Submitter: 142.77.11.120
----
Manual Page -- http://www.php.net/manual/en/language.oop5.visibility.php
Edit -- https://master.php.net/note/edit/73977
Del: integrated -- https://master.php.net/note/delete/73977/integrated
Del: useless -- https://master.php.net/note/delete/73977/useless
Del: bad code -- https://master.php.net/note/delete/73977/bad+code
Del: spam -- https://master.php.net/note/delete/73977/spam
Del: non-english -- https://master.php.net/note/delete/73977/non-english
Del: in docs -- https://master.php.net/note/delete/73977/in+docs
Del: other reasons-- https://master.php.net/note/delete/73977
Reject -- https://master.php.net/note/reject/73977
Search -- https://master.php.net/manage/user-notes.php