Static methods are the functions of a class, which are used directly without creating class object.
Syntax
class classname{
static function functionname(arguments){
// set of statements
}
}
static functions/methods are defined using static keyword then function keyword and functionname.
Example
class myClass{
static function myStaticFunction(){
echo "Hello";
}
}
Accessing static method
To access or use static method of a class, classname with scope resolution operator i.e. :: and static method name is used. No object is needed to access static method.
Example
class myClass{
static function myStaticFunction(){
echo "Hello";
}
}
// Accessing static method with classname and scope resolution operator
myclass::myStaticFunction();