ep9_oop_constructors.php
<?php
class Car {
public $color;
public $model;
public $brand;
public function __construct($color, $model , $brand){
$this->color = $color;
$this->model = $model;
$this->brand = $brand;
}
function getCarMake(){
return "The car brand is $this->brand and the model is $this->model and the color is $this->color";
}
}
$carOne = new Car("white" , "safari" , "Tata");
$carTwo = new Car("black" , "scorpio" , "Mahindra");
Output
Output for this tutorial goes here.
The car brand is Tata and the model is safari and the color is white The car brand is Mahindra and the model is scorpio and the color is black