|
Posted by Vince Morgan on 04/20/07 22:32
"Steve" <no.one@example.com> wrote in message
news:1P9Wh.1936$lq2.1174@newsfe04.lga...
> yes, but here i must agree with the others. the reason why this works is
> because you don't have the object's interface exposed. therefore, php
> executes __set/__get. so in this case, the other posters are correct.
>
> what the op is wanting to do with __set/__get is actually define a public
> var and handle its getting/setting with private methods. the op proposed
> that __set/__get would be the middle-man. it won't in any current release
of
> php. i'm hoping in future versions that it will, as this would make it
very
> similar to other oop enabled scripting languages...those that are more
> robust at present.
>
>
Ok, now, at last I think I've got it. _set; __get; etc. are native
functions. They exist transparently at all times without requiring you to
implement them. Member vars with a public interface are in effect set end
errr, getted, gotten begetted, begotten whatever, via these normaly
transparent functions. Once you implement these member functions yourself
you are in effect 'overloading' these normaly 'transparent' equivelants.
Therefore, if you access a public member property, and have these functions
defined yourself, php effectively ignores your definition and uses it's own
transparent equivelants with regard to those member vars with public
interfaces.
So, when you define __set(), and __get(), the engine will only allow you to
use the 'overloaded' functions on private, or protected interfaces (I'm
guessing about protected, I haven't tried them). Therefore, in effect,
__get() and __set() __are__ the interfaces in and of themselves.
An error or warning would be to alert you to the fact that your implemented
__get() and or __set() are not being utalized by the engine, and it uses
it's own native versions.
Now I understand why I just couldn't grasp what was being meant by
'overload' in the context of these functions.
Sorry about the verbosity, but if I have anything incorrect I'd rather it
not be overlooked ;)
Thank you very much for your patience. My grey putty is slow to take on new
shapes sometimes, perhaps more than sometimes. :]
Regards,
Vince
[Back to original message]
|