3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $mode = '12345' $length = 8 $small = 'abcdefghijklmnopqrstuvwxyz'; $large = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $numeric = '0123456789'; switch ($mode) { // 小文字英字 case 'small': $chars = $small; break; // 大文字英字 case 'large': $chars = $large; break; // 小文字英数字 case 'smallalnum': $chars = $small . $numeric; break; // 大文字英数字 case 'largealnum': $chars = $large . $numeric; break; // 数字 case 'num': $chars = $numeric; break; // 大小文字英字 case 'alphabet': $chars = $small . $large; break; // 大小文字英数字 case 'alnum': default: $chars = $small . $large . $numeric; break; } $charsLength = strlen($chars); $password = ''; for ($i = 0; $i < $length; ++$i) { $num = mt_rand(0, $charsLength - 1); $password .= $chars{$num}; } echo $password;
Output for 5.4.0 - 5.4.25
Parse error: syntax error, unexpected '$length' (T_VARIABLE) in /in/jhZa6 on line 4
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_VARIABLE in /in/jhZa6 on line 4
Process exited with code 255.