Php universal function set (2 ). Function name: CheckWebAddr ($ C_weburl) function: determines whether the URL is valid. parameter: $ C_weburl (URL to be checked) return value: Boolean value remarks: no ---------- // Function name: checkWebAddr ($ C_weburl)
// Usage: Determine whether the website is valid
// Parameter: $ C_weburl (URL to be detected)
// Return value: Boolean
// Standby Note: None
// Configure //-----------------------------------------------------------------------------------
-------
Function CheckWebAddr ($ C_weburl)
{
If (! Ereg ("^ http: // [_ a-zA-Z0-9-] + (. [_ a-zA-Z0-9-] +) * $", $ C_weburl ))
{
Return false;
}
Return true;
}
// Configure //-----------------------------------------------------------------------------------
-------
// Configure //-----------------------------------------------------------------------------------
-------
// Function name: CheckEmpty ($ C_char)
// For usage: determines whether the string is null.
// Parameter: $ C_char (string to be detected)
// Return value: Boolean
// Standby Note: None
// Configure //-----------------------------------------------------------------------------------
-------
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 is set
If ($ C_char =) return false; // whether it is null
Return true;
}
// Configure //-----------------------------------------------------------------------------------
-------
// Configure //-----------------------------------------------------------------------------------
-------
// Function name: CheckLengthBetween ($ C_char, $ I _len1, $ I _len2 = 100)
// For usage: determines whether the string is within the specified length
// Parameter: $ C_char (string to be detected)
// $ I _len1 (lower limit of the target string length)
// $ I _len2 (maximum length of the target string)
// Return value: Boolean
// Standby Note: None
// Configure //-----------------------------------------------------------------------------------
-------
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;
}
// Configure //-----------------------------------------------------------------------------------
-------
// Configure //-----------------------------------------------------------------------------------
-------
// Function name: CheckUser ($ C_user)
// Usage: determines whether the user name is valid
// Parameter: $ C_user (user name to be detected)
// Return value: Boolean
// Standby Note: None
// Configure //-----------------------------------------------------------------------------------
-------
Function CheckUser ($ C_user)
{
If (! CheckLengthBetween ($ C_user, 4, 20) return false; // width check
If (! Ereg ("^ [_ a-zA-Z0-9] * $", $ C_user) return false; // special character check
Return true;
}
// Configure //-----------------------------------------------------------------------------------
-------
// Configure //-----------------------------------------------------------------------------------
-------
// Function name: CheckPassword ($ C_passwd)
// Usage: determines whether the password is valid.
// Parameter: $ C_passwd (password to be detected)
// Return value: Boolean
// Standby Note: None
// Configure //-----------------------------------------------------------------------------------
-------
Function CheckPassword ($ C_passwd)
{
If (! CheckLengthBetween ($ C_passwd, 4, 20) return false; // width detection
If (! Ereg ("^ [_ a-zA-Z0-9] * $", $ C_passwd) return false; // special character detection
Return true;
}
// Configure //-----------------------------------------------------------------------------------
-------
// Configure //-----------------------------------------------------------------------------------
-------
Http://www.bkjia.com/PHPjc/532631.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/532631.htmlTechArticle// function name: CheckWebAddr ($ C_weburl) // used: determines whether it is a valid url // parameter: $ C_weburl (URL to be checked) // return value: boolean value // standby Note: None //----------...