3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function getBatchSize(int $totalRecordsCount) : int { $batchSize = (int) ceil($totalRecordsCount / 5000); $roundDivisor = pow(10, strlen((string) $batchSize) - 1); $batchSize = (int) ceil($batchSize / $roundDivisor) * $roundDivisor; return max( 10, min(100, $batchSize) ); } var_dump(getBatchSize(5), '---'); var_dump(getBatchSize(17), '---'); var_dump(getBatchSize(173), '---'); var_dump(getBatchSize(212522), '---'); var_dump(getBatchSize(2125223), '---');
based on vd26s
Output for 7.0.0 - 7.3.0alpha1
int(10) string(3) "---" int(10) string(3) "---" int(10) string(3) "---" int(50) string(3) "---" int(100) string(3) "---"
Output for 5.6.0 - 5.6.28
Parse error: syntax error, unexpected ':', expecting '{' in /in/kFuRH on line 3
Process exited with code 255.