<html>
<body>
class Car {
public $color;
public $model;
public function __construct($color, $model) {
$this->color = $color;
$this->model = $model;
}
public function message() {
return "My car is a " . $this->color . " " . $this->model . "!";
}
}
$myCar = new Car("black", "Volvo");
echo $myCar -> message();
echo "<br>";
$myCar = new Car("red", "Toyota");
echo $myCar -> message();
</body>
<!-- Mirrored from www.w3schools.com/php/phptryit.asp?filename=tryphp_datatypes_object by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 21 Dec 2022 16:49:33 GMT -->
</html>