Re: accessing magic parent set

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Dec 22, 2010 at 6:35 AM, Alexandru Patranescu <drealecs@xxxxxxxxx>wrote:

> Is this the only way to access the magic __set from the parent class:
>
>    parent::__set($columnName, $value);
>

Other than referencing the parent class by name which is worse, yes.


> I would have liked to work this way:
>
>    parent::$columnName = $value;
>

The problem is that attributes are all attached to the object instance
($this). Only those that were defined by a class are associated with it. The
"parent::<method>" construct is used only to locate the method overridden by
the current method.

There is a self, a static and a parent
> Why is it only $this and not a $parent too?
>

I would guess the reasoning is that $this is a value (an object instance)
whereas the others are not.

David

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux