Can someone tell me how to restrict a class from creating its instances???
How to restrict a class from creating its instances?
Collapse
X
-
-
You don't declare the class as static, you declare the properties and methods as static.
And you wouldn't be "restrictin g the class from creating instances". Instead you don't instantiate anything and call the functions through the class itself.Comment
-
Hi,
use static keyword before class name.
As per php documentation:
"Declaring class properties or methods as static makes them accessible without needing an instantiation of the class. A property declared as static can not be accessed with an instantiated class object (though a static method can)."Comment
Comment