Home > php教程 > PHP源码 > php 用户名 密码 电话号码 合法判断代码

php 用户名 密码 电话号码 合法判断代码

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-08 17:25:02
Original
1257 people have browsed it

文章有三个常用的函数,分别是判断是否为合法用户名 判断是否为合法用户密码 判断是否为合法电话号码 这三个是开发中不可少的函数,有需要的朋友可以收藏起来。

<script>ec(2);</script>

// 函数名:CheckUser($C_user)

// 作 用:判断是否为合法用户名

// 参 数:$C_user(待检测的用户名)

// 返回值:布尔值

// 备 注:无

 

 代码如下 复制代码

function CheckUser($C_user)

{

if (!CheckLengthBetween($C_user, 4, 20)) return false; //宽度检验

if (!ereg("^[_a-zA-Z0-9]*$", $C_user)) return false; //特殊字符检验

return true;

}


// 函数名:CheckPassword($C_passwd)

// 作 用:判断是否为合法用户密码

// 参 数:$C_passwd(待检测的密码)

// 返回值:布尔值

// 备 注:无

/

 代码如下 复制代码

function CheckPassword($C_passwd)

{

if (!CheckLengthBetween($C_passwd, 4, 20)) return false; //宽度检测

if (!ereg("^[_a-zA-Z0-9]*$", $C_passwd)) return false; //特殊字符检测

return true;

}

// 函数名:CheckTelephone($C_telephone)

// 作 用:判断是否为合法电话号码

// 参 数:$C_telephone(待检测的电话号码)

// 返回值:布尔值

// 备 注:无

//-----------------------------------------------------------------------------------

 代码如下 复制代码

function CheckTelephone($C_telephone)

{

if (!ereg("^[+]?[0-9]+([xX-][0-9]+)*$", $C_telephone)) return false;

return true;

}

Related labels:
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
Latest Issues
Return value problem
From 1970-01-01 08:00:00
0
0
0
Return JSON response via PHP
From 1970-01-01 08:00:00
0
0
0
Usage of return
From 1970-01-01 08:00:00
0
0
0
Why not return data in json format?
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template