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

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Please respect the following rules: No advertising, no spam, no keyword in name field. Thank you!