3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function GetLuhnCheckDigit($number) { $sum = 0; $alt = true; $digits = str_split($number); for ($i = count($digits) - 1; $i >= 0; $i--) { $curDigit = $digits[$i]; if ($alt) { $curDigit *= 2; if ($curDigit > 9) $curDigit -= 9; } $sum += $curDigit; $alt = false; } if (($sum % 10) == 0 ){ return 0; } echo abs($sum) . PHP_EOL; return (10 - (abs($sum) % 10)); } echo GetLuhnCheckDigit(12345678912345678918);
based on 0u9qe
Output for 7.1.0 - 7.2.0
Warning: A non-numeric value encountered in /in/tM4L0 on line 14 Warning: A non-numeric value encountered in /in/tM4L0 on line 14 Warning: A non-numeric value encountered in /in/tM4L0 on line 14 71 9
Output for 5.3.19 - 7.0.20
71 9