Re: private, protected, readonly, public
From: Bastian Grupe Date: Fri, 12 May 2006 15:40:20 +0000 Subject: Re: private, protected, readonly, public References: 1 Groups: php.internals Request: Send a blank email to [email protected] to get a copy of this message
Jason Garber wrote:Would it be possible to create a new object property attribute:Uhh... how about using private and only using a "regular" getter (the Java-style) and no setter? class xx {readonlyclass xx {readonly $bar;} $o = new xx(); $o->bar = 10;This way, PHP would allow reading (as if it were public), but only allow writing from within the class.FATAL ERRORprivate $bar;public getBar() { return $bar; }} $o = new xx(); $o->bar = 10; // already emits FATAL ERROR
Thread (92 messages)
« previous | php.internals (#23309) | next » |
---|