"Warning": Do not modify without permission
//-----------------------------------------------------------------------------------
-------
//-----------------------------------------------------------------------------------
-------
//
"File name": C_check.inc
"Function": Universal set of test functions
"Author": Tian Ash
//
"Last Modified Date": 2001/05/11[cxx]
"Variable definition rule": ' c_ ' = character type, ' i_ ' = integer, ' n_ ' = numeric, ' L_ ' = boolean, ' a_ ' = number
Group type
//-----------------------------------------------------------------------------------
-------
//-----------------------------------------------------------------------------------
-------
※checkmoney ($C _money) Check if the data is
99999.99 format
※CHECKEMAILADDR ($C _mailaddr) to determine if it is a valid mail
Access
※CHECKWEBADDR ($C _weburl) to determine if it is a valid URL
※checkempty ($C _char) to determine if a string is empty
※checklengthbetween ($C _char, $I _len1, $I _len2=100) determines whether the specified length is within
String
※checkuser ($C _user) to determine if it is a valid user name
※checkpassword ($C _passwd) to determine whether it is a legitimate user secret
Code
※checktelephone ($C _telephone) to determine if the phone number is legal
Code
※checkvaluebetween ($N _var, $N _val1, $N _val2) to determine whether it is within a certain range
Legal value
※checkpost ($C _post) to determine whether it is a legitimate postcode (solid
Fixed length)
※checkextendname ($C _filename, $A _extend) determine the extension of the uploaded file
※checkimagesize ($ImageFileName, $LimitSize) Verify the size of the uploaded image
※alertexit ($C _alert, $I _goback=0) Illegal operation warning and exit
※alert ($C _alert, $I _goback=0) Illegal operation warning
※replacespacialchar ($C _char) special character substitution function
※exchangemoney ($N _money) Money conversion function
※windowlocation ($C _url, $C _get= "", $C _getother= "") Window.location in PHP
Function
//-----------------------------------------------------------------------------------
-------
//-----------------------------------------------------------------------------------
-------
Function name: Checkmoney ($C _money)
Role: Check whether the data is in 99999.99 format
Parameters: $C _money (number to be detected)
Return Value: Boolean value
Remark: None
//-----------------------------------------------------------------------------------
-------
function Checkmoney ($C _money)
{
if (!ereg ("^[0-9][.") [0-9]$ ", $C _money)) return false;
return true;
}
//-----------------------------------------------------------------------------------
-------
//-----------------------------------------------------------------------------------
-------
Function name: checkemailaddr ($C _mailaddr)
Role: Determine whether a valid email address
Parameters: $C _mailaddr (e-mail address to be detected)
Return Value: Boolean value
Remark: None
//-----------------------------------------------------------------------------------
-------
function checkemailaddr ($C _mailaddr)
{
if (!eregi ("^[_a-z0-9-]+ (. [ _a-z0-9-]+) *@[a-z0-9-]+ (. [ a-z0-9-]+) *$ ",
$C _mailaddr))
(!ereg ("^[_a-za-z0-9-]+ (. [ _a-za-z0-9-]+) *@[_a-za-z0-9-]+ (. [ _a-za-z0-9-]+) *$ ",
$c _mailaddr))
{
return false;
}
return true;
}
//-----------------------------------------------------------------------------------
-------
//-----------------------------------------------------------------------------------
-------
Function name: checkwebaddr ($C _weburl)
Function: Determine if it is a valid URL
Parameters: $C _weburl (URL to be detected)
Return Value: Boolean value
Remark: None
//-----------------------------------------------------------------------------------
-------
function checkwebaddr ($C _weburl)
{
if (!ereg ("^http://[_a-za-z0-9-]+ (. [ _a-za-z0-9-]+) *$ ", $C _weburl))
{
return false;
}
return true;
}
//-----------------------------------------------------------------------------------
-------
//-----------------------------------------------------------------------------------
-------
Function name: Checkempty ($C _char)
Function: Determines whether the string is empty
Parameters: $C _char (string to be detected)
Return Value: Boolean value
Remark: None
//-----------------------------------------------------------------------------------
-------
function checkemptystring ($C _char)
{
if (!is_string ($C _char)) return false; Whether it is a string type
if (Empty ($C _char)) return false; Whether it has been set
if ($C _char== ") return false; is empty
return true;
}
//-----------------------------------------------------------------------------------
-------
//-----------------------------------------------------------------------------------
-------
Function name: Checklengthbetween ($C _char, $I _len1, $I _len2=100)
Function: Determines whether the string is within the specified length
Parameters: $C _char (string to be detected)
$I _len1 (the lower bound of the target string length)
$I _len2 (upper limit of target string length)
Return Value: Boolean value
Remark: None
//-----------------------------------------------------------------------------------
-------
function Checklengthbetween ($C _cahr, $I _len1, $I _len2=100)
{
$C _cahr = Trim ($C _cahr);
if (strlen ($C _cahr) < $I _len1) return false;
if (strlen ($C _cahr) > $I _len2) return false;
return true;
}
//-----------------------------------------------------------------------------------
-------
//-----------------------------------------------------------------------------------
-------
Function name: CheckUser ($C _user)
Role: Determine whether a valid user name
Parameters: $C _user (user name to be detected)
Return Value: Boolean value
Remark: None
//-----------------------------------------------------------------------------------
-------
function CheckUser ($C _user)
{
if (! Checklengthbetween ($C _user, 4,)) return false; Width test
if (!ereg ("^[_a-za-z0-9]*$", $C _user)) return false; Special character test
return true;
}
//-----------------------------------------------------------------------------------
-------
//-----------------------------------------------------------------------------------
-------
Function name: Checkpassword ($C _passwd)
Role: Determine if the password is a valid user
Parameters: $C _passwd (password to be detected)
Return Value: Boolean value
Remark: None
//-----------------------------------------------------------------------------------
-------
function Checkpassword ($C _passwd)
{
if (! Checklengthbetween ($C _passwd, 4,)) return false; Width detection
if (!ereg ("^[_a-za-z0-9]*$", $C _passwd)) return false; Special character detection
return true;
}
//-----------------------------------------------------------------------------------
-------
Current 1/3 page 123 next page
The above describes the detection you have logged in QQ account PHP Universal detection function set 1th/3 page, including the detection of your QQ account has been logged in the content, I hope that the PHP tutorial interested friends have helped.