model = $model;
}
public function getModel() {
return $this->model;
}
}
// Create an object
$myCar = new Car();
// Accessing the private property via public methods
$myCar->setModel(“Honda”);
// Attempting to access the private property directly (will cause an error)
$myCar->model = “Toyota”; // Error: Cannot access private property
echo $myCar->getModel(); // Output: Honda
?>