Why do I need the brackets to add $a + $b
below:
<?php declare(strict_types=1);
function addNumbers(float $a, float $b) : int {
return (int)($a + $b);
}
echo addNumbers(1.2, 5.2);
?>
The used of brackets in cases like this confuses me. Why is an error thrown if the $a + $b
isn't surrounded by brackets? It may be a simple question but study material often doesn't explain detail. Any clarity would be appreciated.