3v4l.org

run code in 300+ PHP versions simultaneously
<?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 - 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.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
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.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.38, 7.0.0 - 7.0.33
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 5.0.0 - 5.0.5
Warning: Missing argument 1 for getToken() in /in/QcFBA on line 16
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9
Warning: Missing argument 1 for gettoken() in /in/QcFBA on line 16

preferences:
332.32 ms | 401 KiB | 420 Q