class Vehicle { public $model; public function __construct($model) { $this->model = $model; } } class Car extends Vehicle { public $doors; } $car = new Vehicle('Ford'); echo get_class($car); // Output: Vehicle $car->doors = 4; setType($car, 'Car'); echo get_class($car); // Output: Car
$number = 123; echo gettype($number); // Output: integer setType($number, 'string'); echo gettype($number); // Output: stringIn this example, we have a numeric variable and we output its type, which is "integer". We then call the setType function to change its type to "string", and output its type again, which is now "string". Package library: This is a built-in PHP function, so it does not require a package library.