When you declare class method as static then these method can be called without instantiating of the class .
When you declare a method or a variable static then we must use static keyword before declare this and when accessing these method or properties outside the class then we have to use class name followed by ::  then followed by property name.
Example of static method :-
class MyClass {
    public static function myStaticMethod() {
        echo "this is my static method";
    }
}
MyClass::myStaticMethod();
So in this example we have declared our method  static and when we want to access this outside the class we have used our class followed by :: and then method .
                       
                    
0 Comment(s)