|
3.3. Declaring a ClassYou might have noticed from the previous example that declaring a class (an object template) is simple. You use the class keyword, give the class a name, and list all the methods and properties an instance of this class should have: class MyClass { ... // List of methods ... ... // List of properties ... } You may have noticed that, in front of the declaration of the $name property, we used the private keyword. We explain this keyword in detail later, but it basically means that only methods in this class can access $name. It forces anyone wanting to get/set this property to use the getName() and setName() methods, which represent the class's interface for use by other objects or source code. |
|