Peter Ford wrote:
> Jochem Maas wrote:
>> Kiketom wrote:
>>> Hi all.
>>> Yesterday i have looking for the overloading members
>>>
>>> Member overloading
>>> void __set ( string name, mixed value )
>>> mixed __get ( string name )
>>>
>>> As an example i put this code:
>>>
>>> class foo
>>> {
>>> private $ID;
>>> private $Name;
>>> private $LastName;
>> when you declare these three as 'real' members, __get() and __set()
>> will no longer be called - they are only called for non-existent members.
>>
> Nope, that's not true.
Indeed. I did post back to say I was talking ****.
If the members are private, or otherwise inaccessible,
I believe that this was not always the case (i.e. that in
older versions private members behaved the same way as public
members with regard to __get()/__set() - I'm not sure but I think so)
> __get() and __set() are called - I've used this in a few places to provide a
> "read-only" member variable, e.g.:
>
> class foo
> {
> private $bar=0;
>
> public function __get($nm)
> {
> return $this->$nm;
> }
>
> public function __set($nm,$val)
> {
> if ($nm != 'bar')
> {
> $this->$nm = $val;
> }
> }
> }
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php