calling parent constructor in php

by Prakash 2013-06-29 13:01:42

We can call parent class constructor in the child class constructor as follows :


class A{
function __construct{
echo "parent construct called";
}
}

class B extends A{
function __construct{
echo "child construct called";
parent::__construct();
}
}

myobj = new B();

Tagged in:

459
like
0
dislike
0
mail
flag

You must LOGIN to add comments