Re: Extending a Class

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

 



* Phillip S. Baker <phillipsbaker@xxxxxxxxx>:
> Thank you,
>
> This makes allot of sense.
> However one last question about this.
>
> If I access the overrided function from the child class do I access it by.
>
> $instanceofchildclass->parent::someMethod();
>
> OR would I still simply just call it
>
> $instanceofchildclass->someMethod();
>
> And it would get to use the overrided function in the child class??

The child class (assuming it has overridden a method) would access the
original method in the parent with:

    parent::someMethod();

If the child class wishes to access the method it has overridden (i.e.,
it wants to access its own method, not the parent's), it uses:

    $this->someMethod();

The object *instance* only gets to access the overridden method (assuming
it's an instance of the child class):

    $instance->someMethod();

-- 
Matthew Weier O'Phinney           | mailto:matthew@xxxxxxxxxx
Webmaster and IT Specialist       | http://www.garden.org
National Gardening Association    | http://www.kidsgardening.com
802-863-5251 x156                 | http://nationalgardenmonth.org

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[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