PHP |
Values |
Operators |
Functions |
Arrays |
Forms |
Sessions-Cookies |
Classes
A class is a group of objects with related properties and methods. Properties are variables local to the object. Methods are functions local to the object. An object is a template, which instances can be called for use of its properties. Objects are created with the same naming conventions as a variable.
The class command declares a new class, followed by the name of the class. The class definition is declared within { } side brackets. Properties are stored in variables. The var command declares a variable within the class. The new command calls an object, storing it in a new variable. The new variable becomes the instance of the object. The -> operator calls a property from the object...
The output is...
I live in the Northwest!
The function command declares the method. $this is a unique variable for referencing the current object...
The output is...
I travel to the Southwest!