How to call parent constructor from a child class constructor in PHP

1 Answer

0 votes
class Test {
    function __construct() { 
        echo 'parent constructor'; 
    }
}

class Sample extends Test {

    function __construct() {
        parent::__construct();
    }
}

$object = new Sample();


 
/*
run: 
  
parent constructor
  
*/ 

 



answered Sep 8, 2017 by avibootz

Related questions

1 answer 239 views
1 answer 192 views
1 answer 169 views
1 answer 156 views
1 answer 226 views
...