1
2<?php
3class BaseClass {
4 function __construct() {
5 print "In BaseClass constructor\n";
6 }
7}
8
9class SubClass extends BaseClass {
10 function __construct() {
11 parent::__construct();
12 print "In SubClass constructor\n";
13 }
14}
15
16class OtherSubClass extends BaseClass {
17 // inherits BaseClass's constructor
18}
19
20// In BaseClass constructor
21$obj = new BaseClass();
22
23// In BaseClass constructor
24// In SubClass constructor
25$obj = new SubClass();
26
27// In BaseClass constructor
28$obj = new OtherSubClass();
29?>
30
31