3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php mt_srand(42); for ($i = 0; $i < 20; $i++) { $key = generate_key(); $len = strlen($key) echo "{$key} {$len}\n"; } function generate_key() { return base64_urlencode(rand_buffer(48)); } function base64_urlencode($buf) { return str_replace( array('+', '/', '='), array('-', '_', ''), base64_encode($buf) ); } function rand_buffer($n) { if (function_exists("openssl_random_pseudo_bytes")) { return openssl_random_pseudo_bytes($n); } $buf = ""; for ($i = 0; $i < $n; $i++) { $buf .= chr(mt_rand(0, 255)); } return $buf; }
Output for 5.4.0 - 5.4.30
Parse error: syntax error, unexpected 'echo' (T_ECHO) in /in/0Oqsk on line 8
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_ECHO in /in/0Oqsk on line 8
Process exited with code 255.