Php verifies whether the user name starts with a letter and verifies the password instance, php instance

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.