3v4l.org

run code in 300+ PHP versions simultaneously
<?php mt_srand(42); echo generateKey(); function generateKey() { return base64encode(randBuffer(48)); } function base64encode($buf) { $enc = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; return $buf; } function randBuffer($n) { //try { //$buf = openssl_random_pseudo_bytes($n); //} catch (Exception $e) { $buf = ""; for ($i = 0; $i < $n; $i++) { $buf .= ord(mt_rand(0, 255)); } //} return $buf; }

preferences:
29.56 ms | 402 KiB | 5 Q