Through the door: parameter or global
One function takes $total as a parameter, the other uses global $total.
<?php$total = 10;function addParam(int $total): int{ $total += 5; return $total;}function addGlobal(): void{ global $total; $total += 5;}echo addParam($total), PHP_EOL;echo $total, PHP_EOL;addGlobal();echo $total, PHP_EOL;1. Predict the output
Tap the lines in the order you think they print.
- 1…
- 2…
- 3…