Afficher un message
Vieux 25/09/2007, 03h09   #4
Larry Garfield
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] Questions about overloading and visibility in PHP5

On Tuesday 18 September 2007, Andrew Ballard wrote:

> > I'm guessing that the answer to all of my questions is some how
> > wrapped up in visibility and overloading. Unfortunately I cannot find
> > any resource that documents the interactions. TIA.

>
> As I understand it, the __get and __set do not ignore visibility;
> rather, they only work for accessing private members. If a property is
> declared public, it does not need the __get and __set, so they aren't
> used. Likewise, $bar->y is public since it was added dynamically
> outside the class.
>
> Andrew


Untrue. If a property exists, then it is used as-is and
__get()/__set()/__isset()/__unset() are never called. The property behaves
normally, as if those methods were not defined. If they're not defined, the
magic methods do whatever they do, which can include adding more properties
to the object if appropriate (thus bypassing the magic methods in the
future).

--
Larry Garfield AIM: LOLG42
larry@garfieldtech.com ICQ: 6817012

"If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called an idea,
which an individual may exclusively possess as long as he keeps it to
himself; but the moment it is divulged, it forces itself into the possession
of every one, and the receiver cannot dispossess himself of it." -- Thomas
Jefferson
  Réponse avec citation
 
Page generated in 0,04606 seconds with 9 queries