<?php
class house {
public $color;
public $land;
public function __construct($color, $land) {
$this->color = $color;
$this->land = $land;
}
public function message() {
return "My house is " . $this->color . " in color and occupies" . $this->model . " of land!";
}
}
$House = new house("black", "40 meter squares");
echo $House -> message();
echo "<br>";
$House = new house("red", "30 meter square");
echo $House -> message();
?>
//Another example:
class Fruit {
public $fruitname;
public $type;
public function __construct($fruitname, $type) {
$this->color = $fruitname;
$this->model = $type;
}
public function message() {
return "The fruit is a " . $this->fruitname . "and in type, " . $this->type;
}
}
$Fruit = new Car("mango", "Carabao");
echo $Fruit -> message();
echo "<br>";
$Fruit = new Car("apple", "Red Delicious");
echo $Fruit -> message();
?>