1.

Method to create a public static method with example in PHP?

Answer»

Method to create a public STATIC method with example in PHP?
Static method is one of a member of a class which is called DIRECTLY by using the class NAME WITHOUT creating any instance of class. And in PHP we create a static method by using static keyword. Below is the syntax or CODE to create a static method:-

class X
{
public static function testHello()
{
echo 'hello Static method';
}
}

X::testHello();



Discussion

No Comment Found