3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php //DOMANDA: 0x55 0x82 0x30 0x01 0x33 0x33 0x91 //RISPOSTA: 0x55 0x82 0xB0 0x01 0x00 0x05 0x72 function CheckSumCalculation($hex) { $dsum=0; for ($i=1; $i < strlen($hex)-1; $i+=4){ $dsum += hexdec($hex[$i].$hex[$i+1]); } $NotSum = ~$dsum; $ChkSum = substr(dechex($NotSum), -2); return $ChkSum; } $LstIA = array("64","65","66","67","68","69","6A","6B","6C"); foreach ($LstIA as &$addr) { $value = $addr * 2; $DXPcmd = "\$55,\$82,\$10,".$addr.",\$33,\$33"; $DXPcmd .= CheckSumCalculation($DXPcmd); echo "<BR>".$DXPcmd; } ?>
based on nuaYM
Output for 7.1.0 - 7.2.0
<BR>$55,$82,$10,64,$33,$3311<BR>$55,$82,$10,65,$33,$3310<BR>$55,$82,$10,66,$33,$330f<BR>$55,$82,$10,67,$33,$330e<BR>$55,$82,$10,68,$33,$330d<BR>$55,$82,$10,69,$33,$330c Notice: A non well formed numeric value encountered in /in/vVSHY on line 22 <BR>$55,$82,$10,6A,$33,$330b Notice: A non well formed numeric value encountered in /in/vVSHY on line 22 <BR>$55,$82,$10,6B,$33,$330a Notice: A non well formed numeric value encountered in /in/vVSHY on line 22 <BR>$55,$82,$10,6C,$33,$3309
Output for 5.3.22 - 7.0.20
<BR>$55,$82,$10,64,$33,$3311<BR>$55,$82,$10,65,$33,$3310<BR>$55,$82,$10,66,$33,$330f<BR>$55,$82,$10,67,$33,$330e<BR>$55,$82,$10,68,$33,$330d<BR>$55,$82,$10,69,$33,$330c<BR>$55,$82,$10,6A,$33,$330b<BR>$55,$82,$10,6B,$33,$330a<BR>$55,$82,$10,6C,$33,$3309