Types
PHP has scalar, compound, and special types.
What it is
PHP has scalar, compound, and special types.
When to use it
Declare expectations at boundaries and convert validated input explicitly.
Syntax
string | int | float | bool | array | object | nullExample
function total(int $quantity, int $unitCents): int
{
return $quantity * $unitCents;
}Common mistakes
Do not assume request strings are already integers; check range before conversion.