Created
September 15, 2015 09:53
-
-
Save ad3n/749166ba1826a809ebe1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$pwd = '1!'; | |
function checkPassword($pwd, &$errors) { | |
$errors_init = $errors; | |
if (strlen($pwd) < 8) { | |
$errors[] = "Password too short!"; | |
} | |
if (!preg_match("#[0-9]+#", $pwd)) { | |
$errors[] = "Password must include at least one number!"; | |
} | |
if (!preg_match("#[a-zA-Z]+#", $pwd)) { | |
$errors[] = "Password must include at least one letter!"; | |
} | |
return ($errors == $errors_init); | |
} | |
checkPassword($pwd, $abc); | |
var_dump($abc); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment