public readonly variables
| From: | Ashley Sheridan | Date: | Fri, 23 Apr 2010 09:55:45 +0000 |
| Subject: | public readonly variables | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-304463@lists.php.net to get a copy of this message | ||
I know the subject line might sound a bit like an oxymoron, but bear
with me!
What I'd like to have is a property of an object that behaves like a
public variable when it comes to reading, but like a protected one when
it comes to writing, as it would make my code a lot easier to read.
I know about the __get($var) method to magically provide this behaviour,
but from all I've read it can be pretty slow compared to a regular
public variable. I've seen a thread on the dev lists where someone
requested it, but can't find anything in the manual.
Does anyone know if this is available in a later version of PHP, or if
it's implementation is penned for some time in the future?
Thanks,
Ash
http://www.ashleysheridan.co.uk