quick links

What is static methos and variable in oop?

Static methos and variable directly access out site class without create object of that class using ::(scope resolution operator).

class test {
public static $a;//Static variable
}
test::$a = 5;
echo test::$a;

With in class you can access static property by self keyword and if you inherite class than use parent keyword to access static property.

class test {
public static $a;//Static variable
}
class testChild extends test {
public static $b;
function testFunction(){
self::$a = 3;
parent::$b = 5;
}
}

 

About Us

Joomla Web Solution

We love working with PHP, HTML5, CSS3, jQuery and the most-loved content management framework in the world, Joomla!

LIKE US ON FACEBOOK