Re: accessing magic parent set

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

 



Hello,

$this only calls variables inside of a method. In your function, you are
calling a variable that was defined inside of your function called
$columnName. You should past the whole class. Not just the methods.

"The pseudo-variable $this is available when a method is called from within
an object context. $this is a reference to the calling object (usually the
object to which the method belongs, but possibly another object, if the
method is called statically from the context of a secondary object). " taken
from http://www.php.net/manual/en/language.oop5.basic.php

The parent keyword indicates that this is an extended class. You are
referring back to the master class.

Ravi.


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

> Is this the only way to access the magic __set from the parent class:
>
>    public function __set($columnName, $value)
>    {
>        if ($value !== $this->$columnName) {
>            parent::__set($columnName, $value);
>        }
>    }
>
>
> I would have liked to work this way:
>
>    public function __set($columnName, $value)
>    {
>        if ($value !== $this->$columnName) {
>            parent::$columnName = $value;
>        }
>    }
>
>
> And another question.
> There is a self, a static and a parent
> Why is it only $this and not a $parent too?
>

[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