• Overloading in PHP provides means to dynamically create properties and methods.
  • These dynamic entities are processed via magic methods, one can establish in a class for various action types.
  • All overloading methods must be defined as Public.
  • After creating objects for a class, we can access a set of entities that are properties or methods not defined within the scope of the class.
  • Such entities are said to be overloaded properties or methods, and the process is called as overloading.
  • For working with these overloaded properties or functions, PHP magic methods are used.
  • Most of the magic methods will be triggered in object context except __callStatic() method which is used in static context.

Some of the magic methods which are useful for property overloading.

  • __set(): It is triggered while initialising overloaded properties.
  • __get(): It is utilised for reading data from inaccessible Properties.
  • __isset(): This magic method is invoked when we check overloaded properties with the isset() function.
  • __unset(): This function will be invoked on using PHP unset() for overloaded properties.