string and int on parameters. Return types after :.
Goal
Echo a typed total.
<?php
function total(int $units, int $price): int {
return $units * $price;
}
echo total(12, 40), PHP_EOL;<?php
function greet(string $name): string {
return "Hello, " . $name;
}
echo greet("Mombasa"), PHP_EOL;<?php
function busy(int $units): bool {
return $units >= 10;
}
echo busy(12) ? "yes" : "no", PHP_EOL;<?php
$units = 8;
echo gettype($units), PHP_EOL;