This article describes how PHP verifies that the user name starts with a letter and validates the password. Share to everyone for your reference. Specifically as follows:
Verify that the user name starts with a letter and that the authentication password can only be a combination of numbers and letters, three common authentication functions: Verify the format of the mailbox address, verify that the password can only be a combination of numbers and letters, and verify that the username starts with a letter, which is used when the user registers or submits the form.
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;
}
}
/**
* Verify 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 is helpful to the regular expression learning.