Static Methods and Properties: Static Methods and Properties is very useful feature in PHP and in this post i am going to tell you about Static Methods and Properties in PHP with example. If you declare any class property or methods as static then you don't need to create object of class to access that means it can be accessible without creating object of class. You can access directly from class with the help of scope resolution operator (::). You can use static keyword to define static methods and properties. class myClass { static public $variable1 = 5; static public $variable2 = 2; static public function getSum() { $sum=self::$variable1+self::$variable2; print "Sum of two variables is " . $sum; } } echo myClass::$variable1; myClass::getSum(); If you extends the parent class in child class and want to access parent class property then you can use parent keyword. parent::$variable1 Why use static methods and proper...
Trying to Learn new things on drupal.