Edit report at http://bugs.php.net/bug.php?id=39118&edit=1

 ID:                 39118
 Updated by:         ras...@php.net
 Reported by:        steve at mountainmedia dot com
 Summary:            Private members accessible to print_r
 Status:             Bogus
 Type:               Bug
 Package:            Class/Object related
 Operating System:   Fedora Core 4/Linux 2.6.14.3
 PHP Version:        5.1.6
 Block user comment: N
 Private report:     N

 New Comment:

There are many ways to get at private methods and properties. One of
which is 

simply looking at the source code. PHP is not a compiled language. The
visibility 

feature is simply a runtime hint, it is not meant in any way to protect
the code, 

and debugging functions such as var_dump and print_r are going to show
the full 

objects.


Previous Comments:
------------------------------------------------------------------------
[2011-05-29 08:41:08] x at x dot com

Please, this is silly. Private and protected variables should be just
that.

------------------------------------------------------------------------
[2006-10-11 18:56:59] he...@php.net

Why don't you simply disable these functions?

------------------------------------------------------------------------
[2006-10-10 18:19:03] steve at mountainmedia dot com

"print_r(), var_dump() and var_export() will also show protected and
private properties of objects with PHP 5."



Can this behavior be disabled?  A new feature perhaps?

------------------------------------------------------------------------
[2006-10-10 16:47:59] tony2...@php.net

http://php.net/print_r



------------------------------------------------------------------------
[2006-10-10 16:40:16] steve at mountainmedia dot com

"The visibility of a property or method can be defined by prefixing the
declaration with the keywords: public, protected or private. Public
declared items can be accessed everywhere. Protected limits access to
inherited and parent classes (and to the class that defines the item).
Private limits visibility only to the class that defines the item."



How do you see this as not a bug considering that last statement in the
documentation on Visibility in PHP 5 Classes (see
http://us2.php.net/manual/en/language.oop5.visibility.php).



This is either a bug or bad documentation.  In all logic and
understanding, the visibility of a private property should be hidden
from any functions such as print_r, overriding the purpose of print_r.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    http://bugs.php.net/bug.php?id=39118


-- 
Edit this bug report at http://bugs.php.net/bug.php?id=39118&edit=1

Reply via email to