Php universal detection function set (2) determine whether it is a valid url
Source: Internet
Author: User
// Function name: CheckWebAddr ($ C_weburl) // Function: determines whether the URL is valid. // parameter: $ C_weburl (URL to be checked) // return value: boolean value // remarks: none // ------------------------------------------------------------------ // Function name: CheckWebAddr ($ C_weburl)
// For usage: determines 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 it is a string 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)
// For usage: determines whether the user name is a legitimate user name
// 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)
// For usage: determines whether the password is a legitimate user.
// 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 //-----------------------------------------------------------------------------------
-------
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service