| Keyword / Operator |
Use |
| class |
Used to create a class |
| new |
Used to instantiate and object from a class |
| -> |
Used to referance a property or method of an object
EX: $camry->price, the whole string can be assigned a value or read from anywhere if the property price is public |
| $this |
Used to referance properties from within an object (Defined in the class) |
__construct |
the function that is executed when an object is instantiated, can be passed arguments by passing them to the class name in the new statement |
| extends |
used within a clas declaration to indicate that this is a subclass
class car extends vehicle |
| parent:: |
the keyword parent followed by the scope operator is escaping the curent scope (The class we are in) to the parent class's scope |
| Properties and method types |
| Public |
It is like a global variable, Anyone can access it from anywhere in your code, We just write $camry->price and it will print the price |
| Private |
Only from within the enclosing class, this one is most restrictive |
| Protected |
From within the enclosing class and from subclasses using parent:: |