Monday, July 13, 2015

Bangla Object Oriented Programming PHP Part-14 (Magic Methods)

PHP provides built-in interceptor methods (also called magic methods), which are automatically executed in some special cases, when are accessed undefined methods and properties. - Magic methods must be defined with "public" attribute.
 __get(), __set() and  __call()  methods:
The __get() and __set() methods are generally used together and are designed for working with properties that are not defined in a class (or its parents).
  • __get($property) - automatically invoked when an undefined property is accessed 
  • __set($property, $value) - automatically invoked when a value is assigned to an undefined property
  • The __get() method must be defned with one parameter 
  • The __set() must be declared with two arguments. 
  • The __call() method is invoked when an undefined method is called. It must be defined with the following sintax: 
public function __call($method, $arg_array)

How to practice tutorials…

  • Make a team with your friends (Member should be 4/5).
  • Start to practice one tutorial series along with them.
  • Don’t try to collect source code. Type the code while watching the tutorial.
  • If you face any problem, discuss with team members to solve quickly.