3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = generate(); echo $array[0]; echo "<br />"; echo $array[1]; echo "<br />"; echo $array[2]; echo "<br />"; echo $array[3]; echo "<br />"; echo $array[4]; // FUNCTION function generate() { $digilist = "0123456789ABCDEFGHJKLMNPQRTUVWXY"; $ip = gethostbyname('keystone.mwbsys.com'); $long = ip2long($ip); $ipenc = md5($long); //now we generate a new random ID number using the substrings of the digitList string above $id = NULL; $id .= substr($digilist, rand(1, 4), 1); //random number ( adjust where 1,4 is lower boundary or 5,9 is higher boundary) $id .= substr($digilist, rand(10, 20), 1); //then a letter $id .= substr($digilist, rand(21, 31), 1); //another letter $id .= substr($digilist, rand(5, 9), 1); //a number ( adjust where 5,9 is higher boundary or 1,4 is lower boundary) $id .= substr($long, rand(1, 9), 1); //and finally another number ( you can adjust this to high or low) // note in $id if start with high-low-high-low or vice versa combination //ok so now we need to generate an MD5 hash of our ID $st = md5('Licensed'); $duration = md5('Lifetime'); $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 = ""; 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); } } $array = array($id, $key, $st, $duration, $long); //return return $array; }
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught Error: Call to undefined function generate() in /in/BLbmD:1 Stack trace: #0 {main} thrown in /in/BLbmD on line 1
Process exited with code 255.
Output for 5.4.1 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
Fatal error: Call to undefined function generate() in /in/BLbmD on line 1
Process exited with code 255.

preferences:
215.28 ms | 402 KiB | 242 Q