PHP Syntax Datatypes Compound Object

 

- Info:

- Object datatypes can contain multiple items.

- Unlike other datatypes, object's properties and methods must be explicitly declared inside a class.

 

- Example:

- Create PHP Console Application Test.php.

 

Test.php

<?php

class Appliance {

private $_power;

function setPower($status) {

$this->_power = $status;

}

}

$blender = new Appliance(); //Create Object of class Appliance. Optianal brackets.

$blender->setPower("on");

?>