type = $type;
}

protected function getType() {
return $this->type;
}
}

class Car extends Vehicle {
public function showType() {
return $this->getType(); // Accessing protected method within the subclass
}
}

// Create an object of Car
$myCar = new Car();
// Attempting to access the protected property directly (will cause an error)
echo $myCar->type; // Error: Cannot access protected property

$myCar->setType(“Sedan”);
echo $myCar->showType(); // Output: Sedan
?>