Methods

Aka behaviours

  • Internal functions of an object defining what it can do
  • Public be default, but a good idea to specify, just in case, and for good readability

 

This example now shows a method being added to the class:

Save & refresh browser:

Instantiating a Bike Object

A new Bike object has been instantiated, called $myBike

 

The object’s single property, $make, has been assigned a value of: Ducati

 

A method has also been defined that: does something

 

The method can also be called without having the need for an instantiated object, and still: does something
Bike::__set_state(array(
‘make’ => ‘Ducati’,
))

 

 

*Note: parentheses must follow the method name

Leave a Reply