Re: json_encode ignores protected/private class members

From: Date: Sun, 12 Oct 2008 14:08:39 +0000
Subject: Re: json_encode ignores protected/private class members
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-40943@lists.php.net to get a copy of this message
Hi Jaris: > I don't know if I'm using json_encode for something it's not supposed to > do. I'm using it to serialize an object to send it to another > runtime-environment in response to an remote call, just like what I can > do with SOAP, REST or RMI. In this context I don't see much sense in > preventing protected/private data from being transfered. So you are accessing the class from outside. This is exactly the situation where private and protected should not be visible. It's just like you're trying to access private properties from the wrong scope in PHP itself: <?php class c { private $p = 'hidden'; } $o = new c; echo $o->p; // This will fail, as it should. You need to change your architecture to do what you want. --Dan -- T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y data intensive web and database programming http://www.AnalysisAndSolutions.com/ 4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409

« previous php.internals (#40943) next »