Launch offer
Business website $150 USD Custom plugin $200 USD Ready in 5 days
Get a quote
OOP

The parent Keyword

Call parent constructors and methods with parent::.

The parent Keyword — a practical guide to PHP parent keyword with clear examples you can reuse in real projects.

OOP Tutorial Series (33/65). Prefer one article? Read the complete OOP tutorial.

Short description

`parent::` accesses the overridden implementation in the parent class.

parent:: usage

class Model {
    public function __construct(public array $attrs = []) {}
}
class Post extends Model {
    public function __construct(array $attrs = []) {
        parent::__construct($attrs);
    }
}

Leave a reply

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