Page 1 of 1

calling parent class

Posted: Wed Jul 12, 2006 5:31 am
by shiznatix
ok i have to call the parent class but its not that easy. heres what i got in one class:

Code: Select all

$tmp = new $ClassName;

return $tmp;
but I can't do:

Code: Select all

parent::__construct();
since that would be that classes parent, not $tmp's classes parent. There is probably some way to write it but I can't seam to find it. I tried

Code: Select all

$tmp->parent::__construct();
but that gave an error of course. any help?

Posted: Wed Jul 12, 2006 5:50 am
by Jenk
create an extra method:

Code: Select all

public function callParentConstruct ()
{
    parent::__construct();
}
or invoke parent::__construct() within the child class' __construct().

:)