#35822 [Opn->Bgs]: print_r displays private declared objects

From: Date: Tue, 27 Dec 2005 22:49:58 +0000
Subject: #35822 [Opn->Bgs]: print_r displays private declared objects
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-91148@lists.php.net to get a copy of this message
ID: 35822 Updated by: tony2001@php.net Reported By: mattias dot segerdahl at bitcom dot se -Status: Open +Status: Bogus Bug Type: Unknown/Other Function Operating System: All PHP Version: 5.1.1 New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Previous Comments: ------------------------------------------------------------------------ [2005-12-27 23:38:38] mattias dot segerdahl at bitcom dot se Description: ------------ print_r($Class) displays private/protected.. Reproduce code: --------------- <?php class foo { private $bar = array(); protected $foobar = array(); public function __construct() { $this->bar['blah'] = 'asfdsdf'; $this->foobar['blah'] = '0as87d'; } } try { $f = new foo(); print_r($f); } catch (exception $e) { die($e->getMessage()); } ?> Expected result: ---------------- foo Object ( [bar:private] => Array ( [blah] => ) [foobar:protected] => Array ( [blah] => ) ) Actual result: -------------- foo Object ( [bar:private] => Array ( [blah] => asfdsdf ) [foobar:protected] => Array ( [blah] => 0as87d ) ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=35822&edit=1

« previous php.bugs (#91148) next »