RE: [PHP] new Object
| From: | Jon Haworth | Date: | Tue, 29 Apr 2003 14:21:19 +0000 |
| Subject: | RE: [PHP] new Object | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-145657@lists.php.net to get a copy of this message | ||
Hi Piotr,
> and when u use classess like
>
> Objects::method()
>
> u don't have access to variables... so only thing left is to wait for
php5?
You can use get/set methods to access properties like that. You need two
extra methods for each property you want to expose: a "get", which is a
one-liner that just returns the value, and a "set", which does validation
and then sets the value.
It's arguably better to do things like this anyway, because it means you're
always performing the same validation on all sets - if you do it directly
you run the risk of dodgy data in your application.
Cheers
Jon