3v4l.org

run code in 500+ PHP versions simultaneously
<?php declare(strict_types=1); function floatValues(float ...$values): array { return $values; } function integerValues(int ...$values): array { return $values; } $array = floatValues(1.1, 2.1); // [1.1, 2.1] print_r($array); $array = integerValues(1, 2); // [1, 2] print_r($array); $one = 1; var_dump($one); // This should throw TypeError, but converts int to float $array = floatValues($one, 2); // [1, 2] var_dump($array); // This throws TypeError as expected integerValues(1.1, 2.1);

preferences:
21.49 ms | 475 KiB | 4 Q