faqts : Computers : Programming : Languages : PHP : kms : Classes

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

12 of 31 people (39%) answered Yes
Recently 0 of 10 people (0%) answered Yes

Entry

How do I call the parent's constructor without knowing the class name of the parent?

Oct 5th, 2005 16:05
saimon say, Manolo Gómez, Guest,


----------------------------------------------------------------------
in php5 you can did it like this:
class base {
      function __construct($param)
       {
          ...
       }
}
class derived extends base{
  function __construct($param1,$param2)
  {
     parent::__construct($param1);
     $this->var = $param2;
  }
}