What is the equivalent of the java "super" keyword in PHP 5?
php
Solution
All you need is
<?php
class BaseClass {
function __construct() {
print "In BaseClass constructor\n";
}
}
class SubClass extends BaseClass {
function __construct() {
parent::__construct(); // this will call your parent constructor
print "In SubClass constructor\n";
}
}
$obj = new BaseClass();
$obj = new SubClass();
?>
Please read: Constructors and Destructors
Problem
I want to `extend` a `class` : `class figure extends model_base { ... }` , and in the constructor of the class children ( here it is figure ) I want to call its parent's `constructor` : in java we do it by writing `super(arguments);` So how to call parent's constructor in PHP ?