博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
php 验证类
阅读量:7218 次
发布时间:2019-06-29

本文共 2892 字,大约阅读时间需要 9 分钟。

63 || strlen($aDomain[0]) < 1) { return FALSE; } return TRUE; } /* * 函数名称:isNumberLength($theelement, $min, $max) * 简要描述:检查字符串长度是否符合要求 * 输入:mixed (字符串,最小长度,最大长度) * 输出:boolean */ public static function isNumLength($val, $min, $max) { $theelement = trim($val); if (ereg("^[0-9]{" . $min . "," . $max . "}$", $val)) return TRUE; return FALSE; } /* * 函数名称:isNumberLength($theelement, $min, $max) * 简要描述:检查字符串长度是否符合要求 * 输入:mixed (字符串,最小长度,最大长度) * 输出:boolean */ public static function isEngLength($val, $min, $max) { $theelement = trim($val); if (ereg("^[a-zA-Z]{" . $min . "," . $max . "}$", $val)) return TRUE; return FALSE; } /* * 函数名称:isEnglish * 简要描述:检查输入是否为英文 * 输入:string * 输出:boolean */ public static function isEnglish($theelement) { if (ereg("[\x80-\xff].", $theelement)) { return FALSE; } return TRUE; } /* * 函数名称:isChinese * 简要描述:检查是否输入为汉字 * 输入:string * 输出:boolean */ public static function isChinese($sInBuf) { $iLen = strlen($sInBuf); for ($i = 0; $i < $iLen; $i++) { if (ord($sInBuf{$i}) >= 0x80) { if ((ord($sInBuf{$i}) >= 0x81 && ord($sInBuf{$i}) <= 0xFE) && ((ord($sInBuf{$i + 1}) >= 0x40 && ord($sInBuf{$i + 1}) < 0x7E) || (ord($sInBuf{$i + 1}) > 0x7E && ord($sInBuf{$i + 1}) <= 0xFE))) { if (ord($sInBuf{$i}) > 0xA0 && ord($sInBuf{$i}) < 0xAA) {//有中文标点 return FALSE; } } else {//有日文或其它文字 return FALSE; } $i++; } else { return FALSE; } } return TRUE; } /* * 函数名称:isDate * 简要描述:检查日期是否符合0000-00-00 * 输入:string * 输出:boolean */ public static function isDate($sDate) { if (ereg("^[0-9]{4}\-[][0-9]{2}\-[0-9]{2}$", $sDate)) { return TRUE; } else { return FALSE; } } /* * 函数名称:isTime * 简要描述:检查日期是否符合0000-00-00 00:00:00 * 输入:string * 输出:boolean */ public static function isTime($sTime) { if (ereg("^[0-9]{4}\-[][0-9]{2}\-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$", $sTime)) { return TRUE; } else { return FALSE; } } /* * 函数名称:isMoney($val) * 简要描述:检查输入值是否为合法人民币格式 * 输入:string * 输出:boolean */ public static function isMoney($val) { if (ereg("^[0-9]{1,}$", $val)) return TRUE; if (ereg("^[0-9]{1,}\.[0-9]{1,2}$", $val)) return TRUE; return FALSE; } /* * 函数名称:isIp($val) * 简要描述:检查输入IP是否符合要求 * 输入:string * 输出:boolean */ public static function isIp($val) { return (bool) ip2long($val); }}

  

转载地址:http://jvtym.baihongyu.com/

你可能感兴趣的文章
/var/adm/wtmp文件太大该怎么办?
查看>>
反应器模式 vs 观察者模式
查看>>
Algernon's Noxious Emissions POJ1121 zoj1052
查看>>
iOS-数据持久化-对象归档
查看>>
iOS开发UI篇—程序启动原理和UIApplication
查看>>
MUI 里js动态添加数字输入框后,增加、减少按钮无效
查看>>
python pip 更换国内安装源(windows)
查看>>
结对编程2后篇
查看>>
oracle exp 和 imp 数据和表结构互相独立导出导入
查看>>
iphone-common-codes-ccteam源代码 CCNSPredicate.m
查看>>
这次项目中应该注意的问题和应该保持的好习惯
查看>>
python-数据结构化与保存
查看>>
LeetCode - 551. Student Attendance Record I
查看>>
Java用户线程和守护线程
查看>>
ClassLoader类加载机制&&JVM内存管理
查看>>
Caml语句 查询分配给当前用户及当前组
查看>>
记一次源码分析
查看>>
php版本引起的const问题
查看>>
js实现60s倒计时效果
查看>>
【POJ 2176】Folding
查看>>