Properties

Aka attributes 

  • Data type definitions for storing the actual values to be assigned to an individual object
  • Must be defined with a visibility keyword: public, protected, private, final
  • Can also be initialised by assigning a value within the class definition

 

This example shows a property being added to the class:

Save & refresh browser:

Instantiating a Bike Object

A new Bike object has been instantiated, called $myBike

 

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

 

Bike::__set_state(array(

‘make’ => ‘Ducati’,
))

 

 

*Note: the -> (aka small arrow) access operator is used to get or set an object’s attributes

Leave a Reply