OOP objects mimic (imitate) real world objects:
Like real world objects, OOP objects have three characteristics associated with them:
A variable is a container that is assigned to a SINGLE type of data (e.g., firstName = "John").
A function is a container that returns a calculation of numbers (or concatenation of strings) or performs a series of tasks. It can be thought of as a calculator that returns a value or a to do list that get completed. A function can tell an object how it should "function."
NOTE: These characteristics are typically written programmatically using the dot syntax. In PHP, the dot is replaced with "->" symbols.
For example, you typically define an object to have properties and one or more methods:
var person = { firstName : "Bob", lastName : "Jones", age : "53", fullName : function(e) { return this.firstName + " " + this.lastName;} }; alert(person.fullName); // Returns "Bob Jones"
NOTE: The properties were placed on a single line so that you can see the explaination that will be explained below better. Normally, they would be written on several lines.
While both properties and methods are both ASSOCIATED with an object, properties are associated with the variables part of the object (in the example above, firstName, lastName and age) and methods are associated with the functions part of an object. However, without attempting to confuse the matter, ALL of of them (e.g., firstName, lastName, age and fullName) are in reality properties of that object because they are on the left side of the colons (:) which denotes properties and their corresponding values which is usually stated as name/value pairs.