Php verifies whether the user name starts with a letter and verifies the password instance, php instance
This document describes how to verify the password and password of a php user name starting with a letter. Share it with you for your reference. The details are as follows:
Verify that the user name starts with a letter and the verification password can only be a combination of numbers and letters. Three Common verification functions: Verify the email address format, the verification password can only be a combination of numbers and letters and whether the user name starts with a letter. This is used when a user registers or submits a form.
Copy codeThe Code is as follows: 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;
}
}
/**
* Verify that the user name starts with a letter
*/
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;
}
}
/**
* The verification password can only be a combination of numbers and letters
*/
Function is_psd ($ psd)
{
If (preg_match ("/^ (w) {4, 20} $/", $ psd, $ password ))
{
Return true;
}
Else
{
Return false;
}
}
I hope this article will help you learn regular expressions.