PHP OOP

Created with Sketch.

PHP OOP

This PHP OOP series helps you master Object-oriented Programming in PHP.

PHP introduced object-oriented programming features since version 5.0. Object-Oriented programming is one of the most popular programming paradigms based on the concept of objects and classes.

PHP OOP allows you to structure a complex application into a simpler and more maintainable structure.

Section 1. Objects & Classes

Section 2. Constructor and Destructor

  • Constructor – explain to you the constructor concept and how to use it to initialize attributes.
  • Destructor – learn how to use destructor to clean resources when the object is deleted.

Section 3. Properties

  • Typed Properties – show you how to add type hints to class properties.
  • Readonly Properties – use the readonly keyword to define readonly properties that can be initialized once within the class.

Section 4. Inheritance

Section 5. Abstract classes

  • Abstract Class – guide you on abstract classes and how to use them effectively.

Section 6. Interfaces

  • Interface – explain to you the interface concept and how to create interfaces.

Section 7. Polymorphism

  • Polymorphism – explain the polymorphism concept and show you how to implement polymorphism in PHP using abstract classes or interfaces.

Section 8. Traits

  • Traits – introduce you to traits.

Section 9. Static methods & properties

Section 10. Magic Methods

  • Magic methods – understand how the magic methods work in PHP.
  • __toString() – return the string representation of an object.
  • __call() – show you how to use the __call() magic method.
  • __callStatic() – show you how to use the __calStatic() magic method.
  • __invoke() – learn how to define a function object or function by implementing the __invoke() magic method.

Section 11. Working with Objects

  • Serialize Objects– use the serialize() function to serialize an object into a binary string and how to use the __serialize() and __sleep() magic methods
  • Unserialize Objects – guide you on how to use the unserialize() function to convert a serialized string into an object. Also, discuss the __wakeup() and __unserialize() magic methods.
  • Cloning Objects – show you how to copy an object.
  • Comparing Objects – how to compare two objects.
  • Anonymous class – learn how to define a class without a declared name.

Section 12. Namespaces

  • Namespace – learn how to use namespaces to group the related classes.

Section 13. Autoloading

Section 14. Exception Handling

  • try…catch – show you how to use the try…catch statement to handle exceptions that may occur in your script.
  • try…catch…finally – learn how to clean up the resources when an error occurs using the finally block.
  • Throw an exception – guide you on how to throw an exception using the throw statement.
  • Set an Exception Handler – show you how to use the set_exception_handler function to set a global exception handler to catch the uncaught exceptions.

Section 15. Class / Object Functions

  • class_exists – return true if a class exists
  • method_exists – return true if an object or a class has a specific method.
  • property_exists – return true if an object or a class has a specific property.

Leave a Reply

Your email address will not be published.