Classes and Objects in PHP
Learn how to use object-oriented programming in PHP.
StartKey Concepts
Review core concepts you need to learn to master this subject
PHP extends keyword
PHP extends keyword
// Dog class inherits from Pet class.
class Dog extends Pet {
function bark() {
return "woof";
}
}
In PHP, to define a class that inherits from another, we use the keyword extends
:
class ChildClass extends ParentClass { }
The newly defined class can access members with public
and protected
visibility from the base class, but cannot access private
members.
The newly defined class can also redefine or override class members.
Classes and Objects
Lesson 1 of 1
What you'll create
Portfolio projects that showcase your new skills
How you'll master it
Stress-test your knowledge with quizzes that help commit syntax to memory