3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function generateSignature($signatureHash) { $signatureHash = $signatureHash; //generating signature $minVal = (int) -2147483648; $maxVal = (int) 2147483647; $hash = (int) 0; for ($i = 0; $i < strlen($signatureHash); $i++) { $hash = ((int) $hash * 31) + ((int) ord(substr($signatureHash, $i, 1))); if ($hash > $maxVal) { $hash = (int) $hash + (int) $minVal - (int) $maxVal - 1; } else if ($hash < $minVal) { $hash = (int) $hash + (int) $maxVal - (int) $minVal + 1; } } return (int) $hash; } $hash1 = '05MAIN0044JT00001742IDR30534D34314E303034414B3359503459'; $hash2 = '18044515'; echo $signature = generateSignature($hash1) + generateSignature($hash2);
Output for 5.5.24 - 7.2.0
-6967498545339047600
Output for 4.3.0 - 5.0.1, 5.0.3 - 5.4.45
-9223370770756640432
Output for 5.0.2
9.223373294363E+18