Monday, June 29, 2015

Bangla Object Oriented Programming PHP Part-06 (Static properties & methods)

Static properties and methods in php can directly accessible without creating object of class. Your php class will be static class if your all methods and properties of the class is static. Static Methods and Properties in PHP will be treated as public if no visibility is defined.
Static properties of class is a property which is directly accessible from class with the help of ::(scope resolution operator). You can declare static  property using static keyword.
To access a static method or property from within the same class you can also use the "self" keyword. "self" is to classes what the $this pseudo-variable is to objects.
self::$property
self::method_Name()
Notice that the static property use the dollar sign ($).
Static properties cannot be accessed through the object using the arrow operator "->"

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.