3v4l.org

run code in 300+ PHP versions simultaneously
<?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);
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught TypeError: Unsupported operand types: int + string in /in/tM4L0:14 Stack trace: #0 /in/tM4L0(23): GetLuhnCheckDigit(1.2345678912346E+19) #1 {main} thrown in /in/tM4L0 on line 14
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
49.93 ms | 401 KiB | 8 Q