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 internals+get-23309@lists.php.net 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 ERROR
private $bar;
public getBar() { return $bar; }
}
$o = new xx();
$o->bar = 10; // already emits FATAL ERROR