3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ValidateForms{ # Min and Max values for username and passoword const MIN_USERNAME = 4; const MAX_USERNAME = 20; const MIN_PASSWORD = 8; const MAX_PASSWORD = 40; # Regex const REGEX_USERNAME = "/^[A-z0-9_]{" . self::MIN_USERNAME . "," . self::MAX_USERNAME .'}$/'; const REGEX_PASSWORD = "/^[A-z0-9_\\\*\-]{" . self::MIN_PASSWORD . "," . self::MAX_PASSWORD .'}$/'; public static $errors = array( 'username' => array(false, "Invalid username: it must have between " . self::MIN_USERNAME . " and " . self::MAX_USERNAME . " chars."), 'password' => array(false, "Invalid password: it must have between self::MIN_PASSWORD and self::MAX_PASSWORD chars and special chars.") ); } print_r(ValidateForms::$errors); ?>
Output for 7.3.0 - 7.3.30, 7.4.0 - 7.4.23, 8.0.0 - 8.0.11, 8.1rc1 - rc2
Array ( [username] => Array ( [0] => [1] => Invalid username: it must have between 4 and 20 chars. ) [password] => Array ( [0] => [1] => Invalid password: it must have between self::MIN_PASSWORD and self::MAX_PASSWORD chars and special chars. ) )

preferences:
52.58 ms | 460 KiB | 5 Q