As someone suggested, use an enumeration, this way you will be better programmed, and you are sure that your function is called correctly with the car, and not something else:
class CarBrand extends SplEnum { // No value, then undefined const __default = 1; const MERCEDES = 1; const AUDI = 2; } function chooseCar(CarBrand $car) { if (CarBrand::MERCEDES == $car) { echo "Mercedes.\n"; } elseif (CarBrand::AUDI == $car) { echo "Audi.\n"; } } $car = new CarBrand(CarBrand::MERCEDES); chooseCar($car);
source share