In this tutorial, you shall learn about Classes and Objects in PHP, about Object Oriented Programming concepts in PHP, with the help of tutorials for each of these concepts.
Classes and Objects
The following tutorials cover the Object Oriented Programming concepts in PHP language, and cover some of the most occurring use cases.
Object Oriented Programming Concepts
- PHP – Class PHP Tutorial on what a class is, and how to define a class in PHP with syntax and examples.
- PHP – Class Object An instance of a class that has its own set of attributes and methods.
- PHP – Class Encapsulation The process of wrapping data and methods inside a class, and hiding the implementation details from the outside world.
- PHP – Class Inheritance PHP Tutorial to implement class inheritance, how to define a child and parent classes, how to access the properties and methods of parent class, etc.
- PHP – Class Polymorphism The ability of objects to take on multiple forms or behaviors. Polymorphism can be achieved through method overloading or method overriding.
- PHP – Class Abstraction The process of focusing on the essential features of an object and hiding the non-essential details. Abstraction is achieved by defining interfaces or abstract classes.
- PHP – Create a class object PHP Tutorial on how to create an object of a class type using new keyword.
- PHP – Class constructor PHP Tutorial about how to define a constructor function in a class using __constructor().
- PHP – Define property and method with same name PHP Tutorial to define a property and a method with same name in a class, and how to access the property or call the method.
- PHP – Readonly property in class PHP tutorial to declare a readonly property in a class and initialise it via constructor or a class method.
- PHP – Class Constants PHP tutorial to declare a constant property in a class.
Exceptions related to Classes and Objects
- PHP Fatal error: Uncaught Error: Cannot access protected property PHP Tutorial to solve the error raised when we try to access a protected property of a class.