3v4l.org

run code in 200+ php & hhvm versions
<?php <?php generate(); // FUNCTION function generate() { $digilist = "0123456789ABCDEFGHJKLMNPQRTUVWXY"; //now we generate a new random ID number using the substrings of the digitList string above for( $i = 0; $i < 100; $i++) { $three_chars = NULL; $three_chars .= substr( $digilist, rand( 1, 9 ), 1 ); $three_chars .= substr( $digilist, rand( 10, 31 ), 1 ); $three_chars .= substr( $digilist, rand( 10, 31 ), 1 ); if ($i < 10) { $three_chars .= '0'; $three_chars .= $i; } else { $three_chars .= $i; } $id = $three_chars; $key = get_key( $id ); echo $id . ":" . $key . "\n"; } } function get_key( $id ) { $digilist = "0123456789ABCDEFGHJKLMNPQRTUVWXY"; //ok so now we need to generate an MD5 hash of our ID $hash = md5($id); //cycle through the hash 16 (length of key) times (in steps of 2 because each hex bytes is 2 digits long) $i = 0; $key = NULL; for ($i; $i < 32; $i+=2) { //here we convert the next hex value to an integer and perform a bitwise AND operation against '31' //31 is the highest substring value in our digit list. $nextdigit = hexdec(substr($hash, $i, 2)) & 31; //if 'i' is divisable by 8 (every 4 cycles) then we want to add "-" if ((($i % 8) == 0) && ($i > 0)) { $key .= "-".substr($digilist, $nextdigit, 1); } else { $key .= substr($digilist, $nextdigit, 1); } } return $key; }
Output for 7.0.0 - 7.4.0beta2
Parse error: syntax error, unexpected '<', expecting end of file in /in/C1DIs on line 3
Process exited with code 255.
Output for hhvm-3.22.0
Fatal error: Uncaught Error: syntax error, unexpected '<', expecting $end in /in/C1DIs:-1 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.11.1 - 3.21.3
Fatal error: Uncaught Error: syntax error, unexpected '<', expecting $end in /in/C1DIs:3 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.10.1
Fatal error: syntax error, unexpected '<', expecting $end in /in/C1DIs on line 3
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.6.40
Parse error: syntax error, unexpected '<' in /in/C1DIs on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '<' in /in/C1DIs on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/C1DIs on line 3
Process exited with code 255.