Snippets

Use a classes parents constructor

var $foo = new foo();
//will echo “run parent constructor” to the screen.

class foo extends bar {
    public function __construct() {
        parent::__construct();
        // Do constructor stuff here
    }
}

class bar {
    public function __construct() {
        // Do constructor stuff here
        echo "run parent constructor";
    }
}

Share this snippet