3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function ean_checksum($eancode) { $result = false; if(strlen($eancode) == 13) { $check_code = substr($check_code, 12, 1); $eancode = substr($eancode, 0, 12); $oddsum=0; $evensum=0; $total=0; $eanvalue=$eancode; $finalean = strrev(substr($eanvalue,0,12)); for($i=0;$i<strlen($finalean);$i++) { if(($i % 2) == 0) { $oddsum += intval($finalean[$i]); } else { $evensum += intval($finalean[$i]); } } $total = ($oddsum * 3) + $evensum; $check = intval(10 - ceil($total % 10.0)) %10; if($check == $check_code) { $result = true; } } return $result; } $ean = '0744361007208'; echo ean_checksum($ean);
based on Hc4Bc
Output for 5.0.4 - 7.1.0
Notice: Undefined variable: check_code in /in/GuWZO on line 5
Output for 4.3.0 - 5.0.3
Notice: Undefined variable: check_code in /in/GuWZO on line 5