Home >Backend Development >PHP Tutorial >PHP verifies whether the username starts with a letter and verifies the password_PHP tutorial
Verify whether the username starts with a letter and verify that the password can only be a combination of numbers and letters
Three commonly used verification functions Verify email address format Verify password can only be a combination of numbers and letters Verify whether the username starts with a letter code, this is used when users register or submit forms.
function is_email($email) { if (preg_match("/[a-za-z0-9]+@[a-za-z0-9]+.[a-z]{2,4}/",$email,$mail)) { return true; } else { return false; } } /** * 验证用户名是否以字母开头 */ function is_user_name($user) { if (preg_match("/^[a-za-z]{1}([a-za-z0-9]|[._]){3,19}$/",$user,$username)) { return true; } else { return false; } } /** * 验证密码只能为数字和字母的组合 */ function is_ps教程d($psd) { if (preg_match("/^(w){4,20}$/",$psd,$password)) { return true; } else { return false; } }