Home  >  Article  >  Backend Development  >  PHP verify whether the username starts with a letter and verify the password example_PHP tutorial

PHP verify whether the username starts with a letter and verify the password example_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:11:22893browse

Example of php verifying whether the username starts with a letter and verifying the password

This article describes the method of php verifying whether the username starts with a letter and verifying the password. Share it with everyone for your reference. The details are as follows:

Verify that 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 the email address format, verify that the password can only be a combination of numbers and letters, and verify that the username starts with A code starting with a letter, which is used when a user registers or submits a form.

The 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 if the username 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 be helpful to everyone’s regular expression learning.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/930078.htmlTechArticlephp verify whether the user name starts with a letter and verify the password example. This article tells the example of php verifying whether the user name starts with a letter. and methods for verifying passwords. Share it with everyone for your reference. Tool...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn