Tsallaka zuwa abun ciki
Justice Tech School

Inheritance

extends inherits members and parent:: calls the parent. Override methods in the child.

Example
class A { function hi() { return "A"; } }
class B extends A { function hi() { return parent::hi() . "B"; } }
echo (new B)->hi();

Result

AB

Exercise

Inherit from a class.

class B  A {}

Quiz Test

How do you call the parent method?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.