flower_svr/include/regularly.function.inc.php
2021-06-11 16:09:56 +08:00

123 lines
2.4 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**************
@正则验证函数文件
@CopyRight gzhq
@file:regularly.function.inc.php
@author bo 595501464@qq.com
@2017-08-08
***************/
/**
* 功能:判断是否中文字符
* $mystr 要判断的字符串
* 返回true/false
**/
function check_is_cn($mystr){
if(preg_match("/[".chr(228).chr(128).chr(128)."-".chr(233).chr(191).chr(191)."]/",$mystr)){
return true;
}else{
return false;
}
}
/**
* 功能:邮箱地址
* $email
* 字符串
*/
function isemail($email) {
return strlen($email) > 6 && preg_match("/^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/", $email);
}
/**
* 功能:检查是否为一个合法的时间格式
* @param string $time
* @return void
*/
function is_time($time){
$pattern = '/[\d]{4}-[\d]{1,2}-[\d]{1,2}\s[\d]{1,2}:[\d]{1,2}:[\d]{1,2}/';
return preg_match($pattern, $time);
}
/**
* 功能:检查是否为一个合法的日期格式
* @param string $date
*/
function is_date($date){
$pattern = '/^[\d]{4}-[\d]{1,2}-[\d]{1,2}$/';
return preg_match($pattern, $date);
}
/**
* 功能:检查是否为一个合法的手机号码
* @param string $tel
*/
function is_tel($tel){
return $check_tel = preg_match('/^1[34578]\d{9}$/', $tel);
}
/**
* 返回字符串长度
*/
function str_len($str){
preg_match_all("/./us", $str, $matches);
return count(current($matches));
}
/**
*验证是否是整数包括0
*/
function is_number($str){
$pattern = '/^[0-9]d*|0$/';
return preg_match($pattern, $str);
}
/**
*验证整数或小数二位的正则
*/
function is_number_fl($str){
$pattern = '/^[0-9]+(.[0-9]{1,2})?$/';
return preg_match($pattern, $str);
}
/**
* 验证整数或字母结合的正则
*/
function is_number_let($str){
$pattern = '/^[\da-z]+$/i';
return preg_match($pattern, $str);
}
/**
* 验证是否包含特殊字符
*/
function is_filter_str($str){
return preg_match("/[\'.,:;*?~`!@#$%^&+=)(<>{}]|\]|\[|\/|\\\|\"|\|/", $str);
}
/**
*检测密码强度
*/
function is_pws($str){
return preg_match("/^(?![a-zA-z]+$)(?!\d+$)(?![!@#$%^&*\.\+\-~()=_]+$)(?![a-zA-z\d]+$)(?![a-zA-z!@#$%^&*\.\+\-~()=_]+$)(?![\d!@#$%^&*\.\+\-~()=_]+$)[a-zA-Z\d!@#$%^&*\.\+\-~()=_]+$/", $str);
}
/**
* 验证网址
*/
function is_web_url($str){
return preg_match("/^^((https|http|ftp|rtsp|mms)?:\/\/)[^\s]+$/", $str);
}
/**
* 验证中文
*/
function is_cn_str($str){
return preg_match("/^[\x80-\xff]{2,30}$/", $str);
}