+ 1

Any can explain PHP class and how to use it with double colons (::)

Can anyone explain the PHP classes and what is static what is public, private, etc. And we can use double colons to call the class. Thanks in advance

27th Jan 2017, 4:16 PM
Animesh
Animesh - avatar
1 Answer
+ 2
PHP classes serve the same functionality as classes in other OOP language.It is a collection of variables and methods of a particular kind of object.You can create an object of any class using the 'new' keyword. Declaring members of a class static make them accessible without an instantiation of the class(i.e by not creating an object of that class). A property declared static cannot be directly accessed within an instance of a class.A static method can be called on a class using the :: symbol.The syntax is: ClassName::Static_Method_Name(); or ClassName::$static_Propetry; public,protected and private define the scope of the members of a class. public outside code can access this member and extending classes will also inherit it. protected These properties and methods (members) can be referenced only by the object’s class methods and those of any subclasses. private These members can be referenced only by methods within the same class—not by subclasses.
28th Jan 2017, 6:27 AM
Srijan Sengupta