<?php
// Define a class
class Car {
// Define attributes
public $make;
public $model;
public $year;
// Define constructor method
function __construct($make, $model, $year) {
$this->make = $make;
$this->model = $model;
$this->year = $year;
}
}
// Create an object of the Car class
$my_car = new Car("Honda", "Civic", 2021);
// Access the attributes of the object
echo "Make: " . $my_car->make . "<br>";
echo "Model: " . $my_car->model . "<br>";
echo "Year: " . $my_car->year . "<br>";
?>
Make: Honda
Model: Civic
Year: 2021
Car
` class with three attributes (`make`, `model`, and `year`) and a constructor method that initializes these attributes. ->
` operator and prints their values to the screen.