Home > php教程 > php手册 > body text

php验证用户名是否以字母开头与验证密码

WBOY
Release: 2016-06-13 10:59:13
Original
2132 people have browsed it

验证用户名是否以字母开头与验证密码只能为数字和字母的组合代码
三款三种常用验证函数 验证邮箱地址格式  验证密码只能为数字和字母的组合 验证用户名是否以字母开头代码哦,这是用户注册时或提交表单时会用的哦。

 

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;
  }
 }
Copy after login

source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!