static member function in php example
<?php
/**
* we don't need to make object of static variable
* when we want to call function but not constructor then we can use constructor
*/
class A
{
static public $num = 3;
function __construct()
{
}
static function fun1() {
echo "test<br>";
echo self::$num; //static function inside we can't use this keyword.
}
}
$obj = new A();
// echo $obj->num; -we can't access static data like this
// echo $obj->fun1(); -we can't access static data like this
echo A::$num; //we can access static variable like this
echo A::fun1(); //we can access static function like this
?>