3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function crypto_rand_secure($min, $max) { $range = $max - $min; if ($range < 0) return $min; // not so random... $log = log($range, 2); $bytes = (int) ($log / 8) + 1; // length in bytes $bits = (int) $log + 1; // length in bits $filter = (int) (1 << $bits) - 1; // set all lower bits to 1 do { $rnd = hexdec(bin2hex(openssl_random_pseudo_bytes($bytes))); $rnd = $rnd & $filter; // discard irrelevant bits } while ($rnd >= $range); return $min + $rnd; } function getToken($length){ $token = ""; $codeAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $codeAlphabet.= "abcdefghijklmnopqrstuvwxyz"; $codeAlphabet.= "0123456789"; for($i=0;$i<$length;$i++){ $token .= $codeAlphabet[crypto_rand_secure(0,strlen($codeAlphabet))]; } return $token; } getToken(); ?>
Output for 7.1.0
Fatal error: Uncaught ArgumentCountError: Too few arguments to function getToken(), 0 passed in /in/QcFBA on line 27 and exactly 1 expected in /in/QcFBA:16 Stack trace: #0 /in/QcFBA(27): getToken() #1 {main} thrown in /in/QcFBA on line 16
Process exited with code 255.
Output for 5.1.0 - 5.6.28, 7.0.0 - 7.0.14
Warning: Missing argument 1 for getToken(), called in /in/QcFBA on line 27 and defined in /in/QcFBA on line 16 Notice: Undefined variable: length in /in/QcFBA on line 21
Output for hhvm-3.10.0 - 3.12.0
Warning: getToken() expects exactly 1 parameter, 0 given in /in/QcFBA on line 17 Notice: Undefined variable: length in /in/QcFBA on line 21
Output for 5.0.0 - 5.0.5
Warning: Missing argument 1 for getToken() in /in/QcFBA on line 16
Output for 4.3.0 - 4.4.9
Warning: Missing argument 1 for gettoken() in /in/QcFBA on line 16