note 79424 deleted from language.oop5.visibility by betz

From: Date: Tue, 27 Nov 2007 03:15:37 +0000
Subject: note 79424 deleted from language.oop5.visibility by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-132583@lists.php.net to get a copy of this message
Note Submitter: NuK ---- Does anybody know WHY print_r and var_dump can access private member variables? When I read about visibility I assumed this was not going to happen... <?php class test { private $password = 'topsecret'; } $myTest = new test(); echo $myTest -> password; # Fatal error: Cannot access private property... that's fine! print_r($myTest); # test Object # ( # [password:private] => topsecret # ) # WHY ? var_dump($myTest); # object(test)#1 (1) { # ["password:private"]=> # string(9) "topsecret" # } # WHY ? ?>

« previous php.notes (#132583) next »