3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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; }
Output for 7.1.0
494957494955495049495050555056495749494949534956504951494949504950535050505652505350495050495049
Output for 5.2.1 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.0.14
495050505453494951495050494951494951554953505049525053505248525755574949495355495749515049554949
Output for 4.3.0 - 5.2.0
495457505049495050505449524949565049545749494949494850494951574950505350504949505049505050514953